how do i auto-print help when no args are provided?
hello! i love arguably! i have this simple example:
import arguably
@arguably.command
def foo__bar1():
"""some help text"""
print("foo__bar1")
@arguably.command
def foo__bar2():
"""some help text"""
print("foo__bar2")
def main():
arguably.run()
assuming the name of the script is cli, when i do:
cli foo -h
i get a nice help message for the sub commands. however, when i do
cli foo
i get this error:
usage: cli foo [-h] command ...
cli foo: error: the following arguments are required: command
can i configure arguably to always print help when no args/commands are supplied? (this is similar to how cement works)
Hey! Great question. I did this in one of my projects a while back... but I'm afraid I landed on a big hack to make it happen. It looks something like this:
try:
result = arguably.run(always_subcommand=True, strict=True)
except ConsoleHelp:
argv.append("-h")
_reset_arguably(argv)
result = arguably.run(always_subcommand=True, strict=True)
def _reset_arguably(argv: list[str]):
"""this reaches into the internals to reset everything..."""
# I manually raise `ConsoleHelp` in a command where I want to programmatically trigger the help message to show
oof.
This is definitely a feature that's needed.
thanks for the response! where am i getting ConsoleHelp from? also where do i put the try/except block?
This is something I need to add - I'll use this issue for tracking it. Shouldn't be much effort, I'll let you know!