author | Alexander Solovyov <piranha@piranha.org.ua> |
Mon, 13 Jul 2009 19:13:19 +0300 (2009-07-13) | |
changeset 38 | d64102e06c34 |
parent 36 | 0cb832d5f1a9 |
child 41 | 8f651939cab7 |
permissions | -rw-r--r-- |
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
1 |
.. -*- mode: rst -*- |
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
2 |
|
33 | 3 |
============= |
4 |
Finaloption |
|
5 |
============= |
|
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
6 |
|
36 | 7 |
Finaloption is a command line parser, intended to make writing command line |
33 | 8 |
applications easy and painless. It uses built-in Python types (lists, |
9 |
dictionaries, etc) to define options, which makes configuration clear and |
|
10 |
concise. Additionally it contains possibility to handle subcommands (i.e. |
|
11 |
``hg commit`` or ``svn update``). |
|
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
12 |
|
33 | 13 |
JFYI: name is derived from Die Krupps' song Final Option, featured in epigraph. |
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
14 |
|
33 | 15 |
Quick example |
16 |
------------- |
|
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
17 |
|
33 | 18 |
That's simple example to show you example of an option definition:: |
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
19 |
|
33 | 20 |
import sys |
21 |
from finaloption import command |
|
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
22 |
|
33 | 23 |
@command(usage='%name [-n] MESSAGE') |
24 |
def main(message, |
|
25 |
nonewline=('n', False, 'don\'t print a newline')): |
|
26 |
'Simple echo program' |
|
27 |
sys.stdout.write(message) |
|
28 |
if not nonewline: |
|
29 |
sys.stdout.write('\n') |
|
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
30 |
|
33 | 31 |
if __name__ == '__main__': |
32 |
main() |
|
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
33 |
|
33 | 34 |
Running this program will print the help:: |
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
35 |
|
33 | 36 |
echo.py [-n] MESSAGE |
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
37 |
|
33 | 38 |
Simple echo program |
39 |
||
40 |
options: |
|
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
41 |
|
33 | 42 |
-n --nonewline don't print a newline |
43 |
-h --help show help |
|
22
8e56f2a8b90a
initial version of readme
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff
changeset
|
44 |
|
34
e4588c625dcb
readme: link to documentation
Alexander Solovyov <piranha@piranha.org.ua>
parents:
33
diff
changeset
|
45 |
I think this mostly describes what's going to. To learn more, read |
e4588c625dcb
readme: link to documentation
Alexander Solovyov <piranha@piranha.org.ua>
parents:
33
diff
changeset
|
46 |
`documentation`_. |
e4588c625dcb
readme: link to documentation
Alexander Solovyov <piranha@piranha.org.ua>
parents:
33
diff
changeset
|
47 |
|
e4588c625dcb
readme: link to documentation
Alexander Solovyov <piranha@piranha.org.ua>
parents:
33
diff
changeset
|
48 |
.. _documentation: http://hg.piranha.org.ua/finaloption/docs/ |