[Python-de] Kommandozeilen-Interface ähnlich distutils?
Peter Hoffmann
ph at peter-hoffmann.com
Mi Mär 24 15:33:38 CET 2010
Wenn es schnell gehen soll nehme ich dafür immer
http://werkzeug.pocoo.org/documentation/script
z.B: test.py
from werkzeug import script
# actions go here
def action_foo(name=""):
"""action foo does foo"""
pass
def action_bar(id=0, title="default title"):
"""action bar does bar"""
pass
if __name__ == '__main__':
script.run()
Jede Funktion die mit action_* anfängt wird als action angesehen.
python test.py --help ergibt dann:
usage: test.py <action> [<options>]
test.py --help
actions:
bar:
action bar does bar
--id integer 0
--title string default title
foo:
action foo does foo
--name string
Gruss Peter
2010/3/24 Hartmut Goebel <h.goebel at goebel-consult.de>:
> Hallo,
>
> das Kommandozeilen-Interface von distutils ist ziemlich Klasse. Ich
> suche eine *einfache* Möglichkeit ein solches Interface zu bauen. Es
> muss nicht erweiterbar sein, alle Kommandos und Optionen sind bekannt.
>
> Irgendwelche Tipps?
>
> python setup.py --help
> python setup.py --help-commands
> python setup.py bdist --help
> python setup.py bdist --eine-bdists-option
Mehr Informationen über die Mailingliste python-de