summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-03-21 16:25:45 +0100
committerhut <hut@lavabit.com>2012-03-21 16:25:45 +0100
commit26e2fcc7be2b3911f1fe2929dbbb80e43c27d11f (patch)
tree9895851effe9b8029b7ca9809daec6d9b6f3d26c /ranger
parentc908fd3d47459b1059ed14452d6dd46f9c9b5353 (diff)
downloadranger-26e2fcc7be2b3911f1fe2929dbbb80e43c27d11f.tar.gz
ext.rifle: s/way/number/ and better documentation
Diffstat (limited to 'ranger')
-rwxr-xr-xranger/ext/rifle.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index 6f1ecbad..3d7b6261 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -229,15 +229,16 @@ class Rifle(object):
 					count = self._skip
 				yield (count, cmd, self._app_label, self._app_flags)
 
-	def execute(self, files, way=0, label=None, flags=None, mimetype=None):
+	def execute(self, files, number=0, label=None, flags=None, mimetype=None):
 		"""
 		Executes the given list of files.
 
-		The default way to run files is 0.  Specifying way=N means rifle should
-		execute the Nth command whose conditions match for the given files.
+		By default, this executes the first command where all conditions apply,
+		but by specifying number=N you can run the 1+Nth command.
 
 		If a label is specified, only rules with this label will be considered.
-		Specifying the mimetype will override the mimetype returned by `file`.
+
+		If you specify the mimetype, rifle will not try to determine it itself.
 
 		By specifying a flag, you extend the flag that is defined in the rule.
 		Uppercase flags negate the respective lowercase flags.
@@ -249,7 +250,7 @@ class Rifle(object):
 
 		# Determine command
 		for count, cmd, lbl, flags in self.list_commands(files, mimetype):
-			if label and label == lbl or not label and count == way:
+			if label and label == lbl or not label and count == number:
 				cmd = self.hook_command_preprocessing(cmd)
 				command = self._build_command(files, cmd, flags)
 				break
@@ -263,7 +264,7 @@ class Rifle(object):
 		# Execute command
 		if command is None:
 			if found_at_least_one:
-				self.hook_logger("Method number %d is undefined." % way)
+				self.hook_logger("Method number %d is undefined." % number)
 			else:
 				self.hook_logger("No action found.")
 		else:
@@ -313,10 +314,10 @@ def main():
 		raise SystemExit(1)
 
 	if options.p.isdigit():
-		way = int(options.p)
+		number = int(options.p)
 		label = None
 	else:
-		way = 0
+		number = 0
 		label = options.p
 
 	if options.w is not None and not options.l:
@@ -331,7 +332,7 @@ def main():
 			for count, cmd, label, flags in rifle.list_commands(positional):
 				print("%d:%s:%s:%s" % (count, label or '', flags, cmd))
 		else:
-			rifle.execute(positional, way=way, label=label, flags=options.f)
+			rifle.execute(positional, number=number, label=label, flags=options.f)
 
 
 if __name__ == '__main__':