Package: wingcommander
# Wing CommanderStatus: [![Travis Status](https://travis-ci.org/jdost/wingcommander.svg?branch=master)](https://travis-ci.org/jdost/wingcommander)## Making python's `cmd` module betterThe `cmd` module for python makes writing readline applications accessible, this isjust an improved wrapper on this.  It allows for you to create instances easilyusing decorators and comes with a varied toolbelt for handling various use cases ofthe system.## Easy creation```pythonfrom wingcommander import WingCommander, runclass TestShell(WingCommander):pass@TestShell.commanddef hello(cmdr, *args):''' Say hello:echoes 'hello''''print("hello")if __name__ == '__main__':commander = TestShell(name="sample")run(commander)```The `TestShell.command` decorator converts the `hello` function into a command forthe readline instance.  The help text for the command gets pulled from the docstring(can be overriden).## Tab completionYou can include a `completions` argument in the decorator to enable tab completionfor the function as well:```python@TestShell.command(completions=["world", "jdost"])```This takes a function, `dict`, or `list`.  If it is a list, it will completeanything from that list for every argument, if it is a dictionary, it will completea key for the first argument and then one of the values for the second (you can nestdictionaries too).  For a function, it works the same as the [`completedefault`][1]function.[1]: https://docs.python.org/2/library/cmd.html#cmd.Cmd.completedefault## SubshellsWingCommander supports subshells out of the box.  This means that you can importand start another WingCommander command shell inside of an existing one and it willboth denote the state and transition smoothly.## ToolbeltThis also comes with a set of helper functions to ease various output scenarios.### `watch````pythondef cat():f = open("editthis.txt", "r")return [l.strip() for l in f.readlines()]wingcommander.watch(cat)```The first is the `watch` function.  This works in the same way as the unix `watch`command where it will print the output of the supplied function on a determinedfrequency.  The output can be multiline and the area covered will grow as the outputgets larger.  This uses ANSI control characters (has only been tested using `urxvt`for now).### `tablize````pythondef list_users():return [["jdost", "github", "python"],["tester", "twitter", "tweets"]]print(tablize(list_users()))```The `tablize` function takes a list of lists (or dictionaries) and creates analigned output in a table form.  The above command would output:```jdost |  github | pythontester | twitter | tweets```The function takes various optional arguments such as `max_length`, `keys`,`dividers`, `labels`, and `alignment`.* `max_length` is just a number that limits the width any column can be (if it is alist, each number will be applied to the corresponding column)* `keys` is for use with a list of dictionaries, rather than printing all the keys,just the keys in the list will be printed (in the order they are listed)* `dividers` is a list or dictionary giving the characters to use as dividers, theorder is [`VERTICAL`, `HORIZONTAL`, `CROSS`], any omitted will use the defaults,* `VERTICAL` are the pipes that separate the columns, default: `|`* `HORIZONTAL` are the spaces that divide the rows, if empty, no divider is used(default)* `CROSS` is the character used (if both `VERTICAL` and `HORIZONTAL` are set) tomark the intersection of these markers* `labels` is a list of strings that will label the columns* `alignment` is a list of characters that denote how the columns will be aligned,options are `c` for center, `r` for right, and `l` for left, you can also use`tablize.LEFT`, `tablize.CENTER`, and `tablize.RIGHT` (this is preferable)