The simple and limited way is to use
In stander library eg argparse
I would suggest Typer (it's build on Click but make it even easier to use).
Both are good Click has been my favorite for a long time.
Typer take advantage of Python type hints,and use it as useful feature.
Example
From command line.
sys.argv
. In stander library eg argparse
I would suggest Typer (it's build on Click but make it even easier to use).
Both are good Click has been my favorite for a long time.
Typer take advantage of Python type hints,and use it as useful feature.
Example
import typer import pathlib def make(folder_name: str): '''Make a new folder in current folder''' typer.echo(f"Make new folder: {folder_name}") new_folder = pathlib.Path(folder_name) new_folder.mkdir(parents=True, exist_ok=True) if __name__ == "__main__": typer.run(make)
From command line.
G:\div_code\answer\temp λ python rundir.py --help Usage: rundir.py [OPTIONS] FOLDER_NAME Make a new folder in current folder Arguments: FOLDER_NAME [required] Options: --install-completion [bash|zsh|fish|powershell|pwsh] Install completion for the specified shell. --show-completion [bash|zsh|fish|powershell|pwsh] Show completion for the specified shell, to copy it or customize the installation. --help Show this message and exit. # Make G:\div_code\answer\temp λ python rundir.py images Make new folder: images # List G:\div_code\answer\temp λ ls images/ rundir.pySee that get
--help
for free,this should always a CLI(command line interfaces) has as argument.