summaryrefslogtreecommitdiff
path: root/docs/features/commands.rst
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2019-07-16 21:25:16 -0600
committerkotfu <kotfu@kotfu.net>2019-07-16 21:25:16 -0600
commitf94466f207366531253ff92c04d2f6f698f0c038 (patch)
treedc0c11e514a70a45d2aa3223a67042953d607ccf /docs/features/commands.rst
parentf3ae3e129c9205229922463fc5ef57cc413c0ab9 (diff)
downloadcmd2-git-f94466f207366531253ff92c04d2f6f698f0c038.tar.gz
Integrate the unfreefeatures legacy documentation
Diffstat (limited to 'docs/features/commands.rst')
-rw-r--r--docs/features/commands.rst43
1 files changed, 43 insertions, 0 deletions
diff --git a/docs/features/commands.rst b/docs/features/commands.rst
index 3eec2373..6a8fedee 100644
--- a/docs/features/commands.rst
+++ b/docs/features/commands.rst
@@ -1,4 +1,47 @@
Commands
========
+.. _cmd: https://docs.python.org/3/library/cmd.html
+
How to create a command with a ``do_command`` method,
+
+Parsed statements
+-----------------
+
+``cmd2`` passes ``arg`` to a ``do_`` method (or ``default``) as a Statement, a
+subclass of string that includes many attributes of the parsed input:
+
+command
+ Name of the command called
+
+args
+ The arguments to the command with output redirection
+ or piping to shell commands removed
+
+command_and_args
+ A string of just the command and the arguments, with
+ output redirection or piping to shell commands removed
+
+argv
+ A list of arguments a-la ``sys.argv``, including
+ the command as ``argv[0]`` and the subsequent
+ arguments as additional items in the list.
+ Quotes around arguments will be stripped as will
+ any output redirection or piping portions of the command
+
+raw
+ Full input exactly as typed.
+
+terminator
+ Character used to end a multiline command
+
+
+
+If ``Statement`` does not contain an attribute, querying for it will return
+``None``.
+
+(Getting ``arg`` as a ``Statement`` is technically "free", in that it requires
+no application changes from the cmd_ standard, but there will be no result
+unless you change your application to *use* any of the additional attributes.)
+
+