I am going to write something very basic so as to explain what I'm looking to make happen. I have written some code to do some interesting WordPress administration. The program will create instances but also create https settings for apache.
What I would like it to do and where I'm having a problem: (If you run a help on the wp cli you will see exactly what I want to have happen...but I'm not a developer so I'd like some help)
python3 testcommands.py --help
Usage: testcommands.py [OPTIONS] COMMAND [ARGS]...
This is the help
Options:
--help Show this message and exit.
Commands:
https Commands for HTTPS
wp Commands for WP
python3 testcommands.py https --help
Usage: testcommands.py [OPTIONS] COMMAND [ARGS]...
This is the help
Options:
--help Show this message and exit.
Commands:
create Creates config for HTTPS
sync Syncs config for Apache
My basic code:
import click
@click.group()
def cli1():
pass
"""First Command"""
@cli1.command('wp')
def cmd1():
"""Commands for WP"""
pass
@cli1.command('install')
@click.option("--test", help="This is the test option")
def install():
"""Test Install for WP"""
print('Installing...')
@click.group()
def cli2():
pass
"""Second Command"""
@cli2.command('https')
def cmd2():
click.echo('Test 2 called')
wp = click.CommandCollection(sources=[cli1, cli2], help="This is the help")
if __name__ == '__main__':
wp()
Returns:
python3 testcommands.py --help
Usage: testcommands.py [OPTIONS] COMMAND [ARGS]...
This is the help
Options:
--help Show this message and exit.
Commands:
https
install Test Install for WP
wp Commands for WP
I can't figure this out. I don't want install to show here, as it should be underneath wp so as not to show.
Thank you if you can help me out...I'm sure it is simple...or maybe not possible...but thanks anyways.
https
necessary inhttps_create
? – Featured