Commit 5d63282c authored by Casey Strouse's avatar Casey Strouse Committed by GitHub

Merge pull request #1384 from uberhacker/fix-crew-help-switch

Fix crew -h|--help bug
parents 92e97bb8 0dce21d6
...@@ -52,16 +52,18 @@ require_relative 'lib/docopt' ...@@ -52,16 +52,18 @@ require_relative 'lib/docopt'
begin begin
args = Docopt::docopt(DOC) args = Docopt::docopt(DOC)
rescue Docopt::Exit => e rescue Docopt::Exit => e
if ARGV[0] and ARGV[0] != '-h' and ARGV[0] != '--help' then
puts "Could not understand \"crew #{ARGV.join(' ')}\".".lightred puts "Could not understand \"crew #{ARGV.join(' ')}\".".lightred
cmds = ["build", "download", "files", "help", "install", "remove", "search", "update", "upgrade", "whatprovides"] cmds = ["build", "download", "files", "help", "install", "remove", "search", "update", "upgrade", "whatprovides"]
# Looking for similar commands # Looking for similar commands
if ARGV.size >= 1 and not cmds.include?(ARGV[0]) then if not cmds.include?(ARGV[0]) then
similar = cmds.select {|word| edit_distance(ARGV[0], word) < 4} similar = cmds.select {|word| edit_distance(ARGV[0], word) < 4}
if not similar.empty? then if not similar.empty? then
puts "Did you mean?" puts "Did you mean?"
similar.each {|sug| puts " #{sug}"} similar.each {|sug| puts " #{sug}"}
end end
end end
end
puts e.message puts e.message
exit 1 exit 1
end end
...@@ -69,7 +71,6 @@ end ...@@ -69,7 +71,6 @@ end
@opt_keep = args["--keep"] @opt_keep = args["--keep"]
@opt_verbose = args["--verbose"] @opt_verbose = args["--verbose"]
@opt_src = args["--build-from-source"] @opt_src = args["--build-from-source"]
@opt_help = args["--help"]
@device = JSON.parse(File.read(CREW_CONFIG_PATH + 'device.json'), symbolize_names: true) @device = JSON.parse(File.read(CREW_CONFIG_PATH + 'device.json'), symbolize_names: true)
#symbolize also values #symbolize also values
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment