Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@3286ce0398c4:~/repos/tmp# vi yourscript.py
- root@3286ce0398c4:~/repos/tmp# ll
- total 20K
- -rw-r--r-- 1 root root 434 Apr 28 21:58 1
- -rw-r--r-- 1 root root 250 Apr 28 21:11 setup.py
- drwxr-xr-x 2 root root 4.0K Apr 28 21:12 yourscript.egg-info
- -rw-r--r-- 1 root root 612 Apr 28 22:16 yourscript.py
- -rw-r--r-- 1 root root 1.4K Apr 28 22:13 yourscript.pyc
- root@3286ce0398c4:~/repos/tmp# cat setup.py
- from setuptools import setup
- setup(
- name='yourscript',
- version='0.1',
- py_modules=['yourscript'],
- install_requires=[
- 'Click',
- ],
- entry_points='''
- [console_scripts]
- yourscript=yourscript:cli
- ''',
- )
- root@3286ce0398c4:~/repos/tmp# cat yourscript.
- cat: yourscript.: No such file or directory
- root@3286ce0398c4:~/repos/tmp# cat yourscript.py
- import click
- CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
- @click.group(context_settings=CONTEXT_SETTINGS)
- @click.version_option(version='opnfv colorado.0.1 ')
- def cli():
- pass
- @cli.command()
- def initdb():
- click.echo('Initialized the database')
- @cli.command()
- def dropdb():
- click.echo('Dropped the database')
- @cli.command()
- @click.argument('name')
- def hello(name):
- click.echo('Hello %s!' % name)
- @cli.command()
- @click.argument('option', )
- def env(option):
- if option == show:
- click.echo("env show command")
- elif option == status:
- click.echo("env status command")
Advertisement
Add Comment
Please, Sign In to add comment