bin/md2site in md2site-0.1.2 vs bin/md2site in md2site-0.1.4
- old
+ new
@@ -5,11 +5,11 @@
require "optparse"
require "simpleoptparse"
opts = {}
-banner_command_part = %q(Usage: bundle exec ruby bin/md2site )
+banner_command_part = %q(Usage: bundle exec ruby bin/md2site init|setup|make|info)
banner_option_part = <<~_BANNER_END
#init(scafold)
[-i dir] [--init dir]
[--url url]
@@ -28,13 +28,10 @@
[-z] [--zlist]
[-x] [--zindex]
#help
- #testx(execute all process for test)
- [-a dir] [--all dir]
-
#(common)
[-c dir] [--confpath dir] # opts['confPath']
[-d d|v] [--debug d|v]
[-l file] [--logfile file]
#(independent)
@@ -57,11 +54,11 @@
end
def need_help?(params, subcmd)
musts = SUBCMDS[subcmd]
- musts ? musts.each_char.none? {|must| params[must] } : false
+ musts ? musts.each_char.none? {|must| params[must.to_sym] } : false
end
def check_file_exist(*args)
args.shift unless args.first
@@ -87,55 +84,53 @@
if ARGV && ARGV[0] && (ARGV[0][0] != "-")
cmd = ARGV.shift
end
-opts["debug"] = ""
+opts[:debug] = ""
Simpleoptparse::Simpleoptparse.parse(ARGV, opts, BANNER, Md2site::VERSION, nil) do |parser|
- parser.on("-i dir", "--init") {|x| opts["init"] = opts["i"] = x }
- parser.on("--url url") {|x| opts["url"] = x }
+ parser.on("-i dir", "--init") {|x| opts[:init] = opts[:i] = x }
+ parser.on("--url url") {|x| opts[:url] = x }
- parser.on("-w dir", "--zcontents") {|x| opts["zcontents"] = opts["w"] = x }
- parser.on("-g dir", "--getfiles") {|x| opts["getfiles"] = opts["g"] = x }
- parser.on("-u", "--zupdate") {|_x| opts["contentUpdate"] = opts["u"] = true }
+ parser.on("-w dir", "--zcontents") {|x| opts[:zcontents] = opts[:w] = x }
+ parser.on("-g dir", "--getfiles") {|x| opts[:getfiles] = opts[:g] = x }
+ parser.on("-u", "--zupdate") {|_x| opts[:contentUpdate] = opts[:u] = true }
- parser.on("-t target", "--target") {|x| opts["targetCommand"] = opts["t"] = x }
- parser.on("-s subtarget", "--subtarget") {|x| opts["subTargetCommand"] = opts["s"] = x }
+ parser.on("-t target", "--target") {|x| opts[:targetCommand] = opts[:t] = x }
+ parser.on("-s subtarget", "--subtarget") {|x| opts[:subTargetCommand] = opts[:s] = x }
- parser.on("-z", "--zlist") {|_x| opts["zlist"] = opts["z"] = true }
- parser.on("-x", "--zindex") {|_x| opts["zindex"] = opts["x"] = true }
+ parser.on("-z", "--zlist") {|_x| opts[:zlist] = opts[:z] = true }
+ parser.on("-x", "--zindex") {|_x| opts[:zindex] = opts[:x] = true }
- parser.on("-a dir", "--all") {|x| opts["all"] = opts["a"] = x }
+ parser.on("-c confpath", "--confpath") {|x| opts[:confPath] = opts[:c] = x }
+ parser.on("-d [d|v]", "--debug") {|x| opts[:debug] = opts[:d] = x }
+ parser.on("-l file", "--logfile") {|x| opts[:logfile] = opts[:l] = x }
- parser.on("-c confpath", "--confpath") {|x| opts["confPath"] = opts["c"] = x }
- parser.on("-d [d|v]", "--debug") {|x| opts["debug"] = opts["d"] = x }
- parser.on("-l file", "--logfile") {|x| opts["logfile"] = opts["l"] = x }
-
- parser.on("-h", "--help") {|_x| opts["help"] = opts["h"] = true }
+ parser.on("-h", "--help") {|_x| opts[:help] = opts[:h] = true }
end
-if opts["debug"] == "d"
- opts["debug"] = "debug"
-elsif opts["debug"] == "v"
- opts["debug"] = "verbose"
-elsif opts["debug"] == ""
- opts["debug"] = nil
+if opts[:debug] == "d"
+ opts[:debug] = "debug"
+elsif opts[:debug] == "v"
+ opts[:debug] = "verbose"
+elsif opts[:debug] == ""
+ opts[:debug] = nil
else
- opts["debug"] = "debug"
+ opts[:debug] = "debug"
end
-usage(0) if (cmd == "help") || (cmd == "-h") || opts["h"] || opts["help"]
+usage(0) if (cmd == "help") || (cmd == "-h") || opts[:h] || opts[:help]
unless cmd
puts "Error: No subcommand"
puts
usage(0)
end
if (cmd != "init") && (cmd != "testx")
- opts["confPath"] = check_option_confpath(opts["confPath"])
+ opts[:confPath] = check_option_confpath(opts[:confPath])
else
- unless opts["url"]
+ unless opts[:url]
puts "Error: Not specified --url url"
puts
usage(0)
end
end