diff options
| author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-03-16 18:08:57 -0400 |
|---|---|---|
| committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-03-16 18:08:57 -0400 |
| commit | e9819736efaf0263cc9e6198719bbda84b871555 (patch) | |
| tree | a4594232bd9c9d2f7d2849ccb299d7c7370a7362 /docs | |
| parent | 4a4e20601b9c5db378bbdc42ae67f2438fb04652 (diff) | |
| download | cmd2-git-e9819736efaf0263cc9e6198719bbda84b871555.tar.gz | |
Added documentaion
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/freefeatures.rst | 6 | ||||
| -rw-r--r-- | docs/settingchanges.rst | 26 |
2 files changed, 24 insertions, 8 deletions
diff --git a/docs/freefeatures.rst b/docs/freefeatures.rst index 6cebbaf3..dff82de4 100644 --- a/docs/freefeatures.rst +++ b/docs/freefeatures.rst @@ -320,8 +320,8 @@ Additionally, it is trivial to add identical file system path completion to your have defined a custom command ``foo`` by implementing the ``do_foo`` method. To enable path completion for the ``foo`` command, then add a line of code similar to the following to your class which inherits from ``cmd2.Cmd``:: - # Assuming you have an "import cmd2" somewhere at the top - complete_foo = cmd2.Cmd.path_complete + # Make sure you have an "import functools" somewhere at the top + complete_foo = functools.partial(path_complete) This will effectively define the ``complete_foo`` readline completer method in your class and make it utilize the same path completion logic as the built-in commands. @@ -332,4 +332,4 @@ path completion of directories only for this command by adding a line of code si which inherits from ``cmd2.Cmd``:: # Make sure you have an "import functools" somewhere at the top - complete_bar = functools.partialmethod(cmd2.Cmd.path_complete, dir_only=True) + complete_bar = functools.partial(path_complete, dir_only=True) diff --git a/docs/settingchanges.rst b/docs/settingchanges.rst index 67292a48..f919d8c8 100644 --- a/docs/settingchanges.rst +++ b/docs/settingchanges.rst @@ -9,12 +9,12 @@ its name is included in the dictionary ``app.settable``. (To define your own user-settable parameters, see :ref:`parameters`) -Shortcuts (command aliases) +Shortcuts =========================== -Command aliases for long command names such as special-character shortcuts for common commands can make life more -convenient for your users. Shortcuts are used without a space separating them from their arguments, -like ``!ls``. By default, the following shortcuts are defined: +Command shortcuts for long command names and common commands can make life more convenient for your users. +Shortcuts are used without a space separating them from their arguments, like ``!ls``. By default, the +following shortcuts are defined: ``?`` help @@ -41,12 +41,28 @@ To define more shortcuts, update the dict ``App.shortcuts`` with the .. warning:: - Command aliases needed to be created by updating the ``shortcuts`` dictionary attribute prior to calling the + Shortcuts need to be created by updating the ``shortcuts`` dictionary attribute prior to calling the ``cmd2.Cmd`` super class ``__init__()`` method. Moreover, that super class init method needs to be called after updating the ``shortcuts`` attribute This warning applies in general to many other attributes which are not settable at runtime such as ``commentGrammars``, ``multilineCommands``, etc. +Aliases +================ + +In addition to shortcuts, ``cmd2`` provides a full alias feature via the ``alias`` command which is similar to the +``alias`` command in Bash. + +The syntax to create an alias is, ``alias <name> <value>``. ``value`` can contain spaces and does not need +to be quoted. Ex: ``alias ls !ls -lF`` + +If ``alias`` is run without arguments, then a list of all aliases will be printed to stdout and are in the proper +``alias`` command syntax, meaning they can easily be reused. + +The ``unalias`` is used to clear aliases. Using the ``-a`` flag will clear all aliases. Otherwise provide a list of +aliases to clear. Ex: ``unalias ls cd pwd`` will clear the aliases called ls, cd, and pwd. + + Default to shell ================ |
