edornd / argdantic

Typed command line interfaces with argparse and pydantic
MIT License
38 stars 4 forks source link

docstring print in help with single command #45

Closed fkgruber closed 6 months ago

fkgruber commented 6 months ago

Hi thanks for the useful tool. When we have a single command why not print the doctring of the function when we do --help?

Suppose I have

from argdantic import ArgParser

cli = ArgParser()

@cli.command()
def hello(name: str):
    """Print a greeting message."""
    print(f"Hello, {name}!")

if __name__ == "__main__":
    cli()

I would like to use it with ./test --name J

but when I do ./test --help I would like to see the documentation of hello: Print a greeting message.

I rather not activate force_group because then I need to use it as

./test hello --name J which is silly since there is only 1 command.

edornd commented 6 months ago

Hi @fkgruber, good catch! That's actually an easy fix, I never noticed it.

fkgruber commented 6 months ago

thanks! Will it be available in pip?

edornd commented 6 months ago

Sorry if it took two geological eras, the small fix is now on PyPI!