hint about adding option lists
authorAlexander Solovyov <piranha@piranha.org.ua>
Mon, 13 Jul 2009 19:13:19 +0300
changeset 38 d64102e06c34
parent 37 f61f1bbbf47d
child 39 c6705e908794
hint about adding option lists
docs/overview.rst
--- a/docs/overview.rst	Mon Jul 13 18:56:11 2009 +0300
+++ b/docs/overview.rst	Mon Jul 13 19:13:19 2009 +0300
@@ -100,7 +100,8 @@
 Naturally ``args`` is a list, containing all arguments to command, and ``opts``
 is a dictionary, containing every option.
 
-After definition of all elements you can call command dispatcher::
+After definition of all elements you can call command dispatcher (``cmdtable``
+is defined earlier)::
 
   from finaloption import dispatch
 
@@ -148,3 +149,16 @@
       --exit  exit with supplied code (default: 0)
    -h --help  show help
 
+
+Tips and tricks
+---------------
+
+There is one thing which may be obvious: it's easy to have "semi-global"
+options. If your subcommands (or scripts) tend to have same options in some
+cases - for example, few commands (not every) can receive database credentials -
+you can define this options in separate list and then add them to command's own
+options, i.e.::
+
+  @command(cmd_opts + dbopts)
+  def select(**opts):
+      pass