diff options
author | hut <hut@lavabit.com> | 2009-07-24 04:17:35 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-07-24 04:17:35 +0200 |
commit | 96f6089e8f1de2c1a38accecb621827730a70a26 (patch) | |
tree | 751fd9202ea17727f104f02b8e66a175fb35a386 | |
parent | ec521b1eaade1c6f8bc8f6fc112cb2e1976bd832 (diff) | |
download | ranger-96f6089e8f1de2c1a38accecb621827730a70a26.tar.gz |
improve argument parsing
-rwxr-xr-x | ranger | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ranger b/ranger index 7d1b7b68..370d52f1 100755 --- a/ranger +++ b/ranger @@ -31,7 +31,7 @@ pwd = nil while arg = ARGV.shift case arg - when '-h', '--help', '-help' + when '-h', '--help', '-help', '--usage', '-usage' puts "usage: ranger [options] [file/directory]" puts "options are:" puts " -h, --help show this message" @@ -50,12 +50,13 @@ while arg = ARGV.shift when '--' break + when /^-/ + puts "ranger: Unrecognized option: #{arg}" + abort "try using `ranger --help'" + else - if ARGV.size > 0 - abort "ranger: Unrecognized option: #{arg}" - else - pwd = arg - end + pwd = arg + break end end @@ -63,7 +64,8 @@ end pwd ||= ARGV.last if pwd - if pwd =~ /^file:\/\// + ## remove "file://" so you can use ranger to open files from firefox + if pwd =~ %r(^file://) pwd = $' end |