about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-07-24 04:17:35 +0200
committerhut <hut@lavabit.com>2009-07-24 04:17:35 +0200
commit96f6089e8f1de2c1a38accecb621827730a70a26 (patch)
tree751fd9202ea17727f104f02b8e66a175fb35a386
parentec521b1eaade1c6f8bc8f6fc112cb2e1976bd832 (diff)
downloadranger-96f6089e8f1de2c1a38accecb621827730a70a26.tar.gz
improve argument parsing
-rwxr-xr-xranger16
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