Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kadirpekel/komandr
Coolest command-line interface on this planet
https://github.com/kadirpekel/komandr
Last synced: 3 months ago
JSON representation
Coolest command-line interface on this planet
- Host: GitHub
- URL: https://github.com/kadirpekel/komandr
- Owner: kadirpekel
- Created: 2012-12-18T12:07:22.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2021-11-22T13:42:30.000Z (about 3 years ago)
- Last Synced: 2024-08-19T05:39:11.860Z (4 months ago)
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 138
- Watchers: 11
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
=======
komandr
=======Convert your ordinary functions into cool command-line interfaces!
Komandr is a smart thin wrapper around powerful ``argparse`` module lets you
build defacto standart command-line interfaces in secondz while providing you
all the flexibity.Example
-------.. code-block:: python
from komandr import *
@command
def foo(bar, baz=None):
print 'foo', bar, bazmain()
Need some help?
.. code-block:: console
$ python example.py --help
usage: example.py [-h] [-v] {foo,cool_command} ...positional arguments:
{foo,cool_command}optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exitLet's investigate more about ``foo``
.. code-block:: console
$ python example.py foo --help
usage: example.py foo [-h] --baz BAZ barpositional arguments:
baroptional arguments:
-h, --help show this help message and exit
--baz BAZTest ``foo`` command
.. code-block:: console
$ python example.py foo Hello
usage: example.py foo [-h] --baz BAZ bar
example.py foo: error: argument --baz is requiredThat's ok now
.. code-block:: console
$ python example.py foo Hello --baz World
foo Hello WorldCool, eh? What if you need more control over?
.. code-block:: python
from komandr import *
@command('cool_command')
@arg('baz', '-z', required=True, type=int)
def lame_command(foo, bar, baz=1):
print 'lame_command', foo, bar, bazmain()
Let's try it
.. code-block:: console
$ python example.py cool_command Hello -z 'wtf' World
usage: example.py cool_command [-h] --baz BAZ foo bar
example.py cool_command: error: argument --baz/-z: invalid int value: 'wtf'Correct one should be
.. code-block:: console
$ python example.py cool_command Hello -z 2013 World
lame_command Hello World 2013Showcase
--------Want to see something real, Checkout Dudu https://github.com/kadirpekel/dudu
Enjoy!
Licence
-------
Copyright (c) 2012 Kadir Pekel.Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the 'Software'), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.