creating a home
how to create a home that will raise when an invalid option or nothing is entered
import cliflect
console=cliflect.console()
@console.home
def error(erropt):
if erropt:
console.echo(f'{erropt} is an invalid option', color='red')
console.echo('''usage hello.py [option] arg...
options:
-h : help''')
else:
console.echo('no option entered', color='red')
console.echo('use -h for help')
@console.cmd('-h')
def help_(arg):
console.echo('you entered help option')
console.run()
at console
$ python hello.py
no option entered
use -h for help
$ python hello.py test
test is an invalid option
usage hello.py [option] arg...
options:
-h -- help
$ python hello.py -h
you entered help option