hx 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/hx/commandline.rb +28 -20
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/hx/commandline.rb
CHANGED
@@ -30,14 +30,19 @@ require 'tempfile'
|
|
30
30
|
module Hx
|
31
31
|
module Commandline
|
32
32
|
|
33
|
-
DEFAULT_CONFIG_FILENAME = "
|
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 =
|
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,
|
129
|
+
do_edit(site, pathspec, nil)
|
115
130
|
end
|
116
131
|
|
117
|
-
def self.
|
118
|
-
|
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,
|
141
|
+
def self.do_edit(site, pathspec, prototype)
|
122
142
|
source_name, path = pathspec.split(':', 2)
|
123
|
-
|
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
|