From aefd8048d2b246c0111ac1227ade2a9a9d38c35c Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 9 Jun 2010 13:11:06 +0200 Subject: renamed "--fail-if-run" to the more accurate "--fail-unless-cd" The old name, --fail-if-run, is still valid and working. --- doc/ranger.1 | 6 +++--- ranger.py | 2 +- ranger/__main__.py | 11 ++++++++--- ranger/help/invocation.py | 9 +++++---- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index b197d774..39c33973 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -33,9 +33,9 @@ Activate the clean mode: Ranger will not access or create any configuration files nor will it leave any traces on your system. This is useful when your configuration is broken, when you want to avoid clutter, etc. .TP ---fail-if-run +--fail-unless-cd Return the exit code 1 if ranger is used to run a file, for example with -`ranger --fail-if-run filename`. This can be useful for scripts. +`ranger --fail-unless-cd filename`. This can be useful for scripts. .TP -r \fIdir\fR, --confdir=\fIdir\fR Define a different configuration directory. The default is $HOME/.ranger. @@ -176,7 +176,7 @@ of your parent shell after exiting ranger: .nf ranger() { - command ranger --fail-if-run $@ && + command ranger --fail-unless-cd $@ && cd "$(grep \\^\\' ~/.ranger/bookmarks | cut -b3-)" } .\"----------------------------------------- diff --git a/ranger.py b/ranger.py index aca1b557..ccc9f0d6 100755 --- a/ranger.py +++ b/ranger.py @@ -23,7 +23,7 @@ # after you exit ranger by starting it with: source ranger ranger """": if [ $1 ]; then - $@ --fail-if-run && cd "$(grep \^\' ~/.ranger/bookmarks | cut -b3-)" + $@ --fail-unless-cd && cd "$(grep \^\' ~/.ranger/bookmarks | cut -b3-)" else echo "usage: source path/to/ranger.py path/to/ranger.py" fi diff --git a/ranger/__main__.py b/ranger/__main__.py index ff5cdc4d..a03509cf 100644 --- a/ranger/__main__.py +++ b/ranger/__main__.py @@ -26,7 +26,7 @@ import sys def parse_arguments(): """Parse the program arguments""" - from optparse import OptionParser + from optparse import OptionParser, SUPPRESS_HELP from ranger import __version__, USAGE, DEFAULT_CONFDIR from ranger.ext.openstruct import OpenStruct parser = OptionParser(usage=USAGE, version='ranger ' + __version__) @@ -35,7 +35,9 @@ def parse_arguments(): help="activate debug mode") parser.add_option('-c', '--clean', action='store_true', help="don't touch/require any config files. ") - parser.add_option('--fail-if-run', action='store_true', + parser.add_option('--fail-if-run', action='store_true', # COMPAT + help=SUPPRESS_HELP) + parser.add_option('--fail-unless-cd', action='store_true', help="experimental: return the exit code 1 if ranger is" \ "used to run a file (with `ranger filename`)") parser.add_option('-r', '--confdir', type='string', @@ -50,6 +52,9 @@ def parse_arguments(): options, positional = parser.parse_args() arg = OpenStruct(options.__dict__, targets=positional) arg.confdir = os.path.expanduser(arg.confdir) + if arg.fail_if_run: + arg.fail_unless_cd = arg.fail_if_run + del arg['fail_if_run'] return arg @@ -185,7 +190,7 @@ def main(): runner = Runner(logfunc=print_function) load_apps(runner, ranger.arg.clean) runner(files=[File(target)], mode=arg.mode, flags=arg.flags) - sys.exit(1 if arg.fail_if_run else 0) + sys.exit(1 if arg.fail_unless_cd else 0) else: path = target else: diff --git a/ranger/help/invocation.py b/ranger/help/invocation.py index 3de574cc..26cffd4a 100644 --- a/ranger/help/invocation.py +++ b/ranger/help/invocation.py @@ -43,9 +43,10 @@ command line. This is useful when your configuration is broken, when you want to avoid clutter, etc. ---fail-if-run +--fail-unless-cd Return the exit code 1 if ranger is used to run a file, for example - with `ranger --fail-if-run filename`. This can be useful for scripts. + with `ranger --fail-unless-cd filename`. This can be useful for scripts. + (This option used to be called --fail-if-run) -r , --confdir= Define a different configuration directory. The default is @@ -69,7 +70,7 @@ command line. Examples: ranger episode1.avi ranger --debug /usr/bin - ranger --confdir=~/.config/ranger --fail-if-run + ranger --confdir=~/.config/ranger --fail-unless-cd ============================================================================== @@ -95,7 +96,7 @@ docstrings. Use this option if you don't need the documentation. Examples: PYTHONOPTIMIZE=1 ranger episode1.avi PYTHONOPTIMIZE=2 ranger --debug /usr/bin - python -OO `which ranger` --confdir=~/.config/ranger --fail-if-run + python -OO `which ranger` --confdir=~/.config/ranger --fail-unless-cd Note: The author expected "-OO" to reduce the memory usage, but that doesn't seem to happen. -- cgit 1.4.1-2-gfad0