hx 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/hx/commandline.rb +28 -20
  3. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -30,14 +30,19 @@ require 'tempfile'
30
30
  module Hx
31
31
  module Commandline
32
32
 
33
- DEFAULT_CONFIG_FILENAME = "hx-config.yaml"
33
+ DEFAULT_CONFIG_FILENAME = "config.hx"
34
34
 
35
35
  def self.main(*args)
36
36
  options = OpenStruct.new
37
37
  options.config_file = nil
38
38
 
39
39
  OptionParser.new do |opts|
40
- opts.banner = "Usage: hx [--config CONFIG_FILE]"
40
+ opts.banner = <<EOS
41
+ Usage: hx [--config CONFIG_FILE] [upgen]
42
+ hx [--config CONFIG_FILE] regen
43
+ hx [--config CONFIG_FILE] post[up] SOURCE:PATH
44
+ hx [--config CONFIG_FILE] edit[up] SOURCE:PATH
45
+ EOS
41
46
 
42
47
  opts.on("-c", "--config CONFIG_FILE",
43
48
  "Use CONFIG_FILE instead of searching for " +
@@ -110,27 +115,32 @@ def self.do_gen(site, update_only)
110
115
  end
111
116
  end
112
117
 
118
+ def self.cmd_editup(site, pathspec)
119
+ cmd_edit(site, pathspec)
120
+ cmd_upgen(site)
121
+ end
122
+
123
+ def self.cmd_postup(site, pathspec)
124
+ cmd_post(site, pathspec)
125
+ cmd_upgen(site)
126
+ end
127
+
113
128
  def self.cmd_edit(site, pathspec)
114
- do_edit(site, pathspec, false)
129
+ do_edit(site, pathspec, nil)
115
130
  end
116
131
 
117
- def self.cmd_create(site, pathspec)
118
- do_edit(site, pathspec, true)
132
+ def self.cmd_post(site, pathspec)
133
+ prototype = {
134
+ 'title' => Hx.make_default_title(site.options, path),
135
+ 'author' => Hx.get_default_author(site.options),
136
+ 'content' => ""
137
+ }
138
+ do_edit(site, pathspec, prototype)
119
139
  end
120
140
 
121
- def self.do_edit(site, pathspec, create)
141
+ def self.do_edit(site, pathspec, prototype)
122
142
  source_name, path = pathspec.split(':', 2)
123
- path, source_name = source_name, path unless source_name
124
-
125
- if create
126
- prototype = {
127
- 'title' => Hx.make_default_title(site.options, path),
128
- 'author' => Hx.get_default_author(site.options),
129
- 'content' => ""
130
- }
131
- else
132
- prototype = nil
133
- end
143
+ raise "Invalid entry specification #{pathspec}" unless path
134
144
 
135
145
  if source_name
136
146
  source = site.sources[source_name]
@@ -163,9 +173,7 @@ def self.do_edit(site, pathspec, create)
163
173
  $stderr.print "Edit failed; retry? [Yn] "
164
174
  $stderr.flush
165
175
  response = $stdin.gets.strip
166
- unless response =~ /^y/i
167
- raise e
168
- end
176
+ raise unless response =~ /^y/i
169
177
  end
170
178
  end
171
179
  ensure
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MenTaLguY