-2

I have a command like :

$trial login --user

For this I used python-click to wrap my python functions and is working fine. I am very new to python-click and having having to construct a command in a certain way than what is mentioned above.

Below is my present code of a file trial.py,

@click.command()
@click.option('--user', prompt='Username', help='Username.')
@click.option('--password', prompt='Password', help='Password.')
def login(user, password):
    """Simple program that greets NAME for a total of COUNT times."""
    login_cli(user,password)
    print "done"

@click.group()
def cli():
    pass

And my setup.py file looks like the following:

from setuptools import setup

setup(
    name='trial',
    version='0.1',
    py_modules=['trial'],
    install_requires=[
        'Click',
    ],
    entry_points='''
        [console_scripts]
        trial=trial:cli
    ''',
)

But now I want to change the command a little. I want to make it something like,

$trial k8s login --user

I want to add a series of k8s commands but don't know how to include it in the code and would want some guidance on the same.

nidHi
  • 833
  • 3
  • 10
  • 21

1 Answers1

-1

You just need to make another group that's a child of cli, so make a k8s function and decorate it with cli.group(), then change login to be a k8s.command()

spruceb
  • 621
  • 5
  • 12