M README.md => README.md +2 -0
@@ 5,6 5,8 @@ Each function will be a subcommand of your application.
*Climatik* define a function decorator which parse function definition and build
a subcommand command line parser.
+Optionally [argcomplete](https://kislyuk.github.io/argcomplete/) is supported.
+
## Docs
### def command(fnc:Callable)
M Taskfile => Taskfile +1 -2
@@ 19,8 19,7 @@ function build {
}
function upload {
- build
- if [ "$1" == "--dist" ]
+ if [ "${1:-}" == "--dist" ]
then
twine upload dist/*
else
M climatik/__init__.py => climatik/__init__.py +9 -2
@@ 8,8 8,12 @@ Each function will be a subcommand of your application.
import inspect
import argparse
from typing import Callable, Optional, TypedDict, Dict, Any, Union, get_origin, get_args
+try:
+ import argcomplete
+except ImportError:
+ argcomplete = None
-__version__ = "0.4.0"
+__version__ = "0.4.1"
class NameClashException(Exception):
pass
@@ 59,6 63,9 @@ def get_parser(*args, **kwargs) -> argparse.ArgumentParser:
for s_name, arg in command['args'].items():
s_parser.add_argument(s_name, **arg)
s_parser.set_defaults(func=command['func'])
+
+ if argcomplete:
+ argcomplete.autocomplete(parser)
return parser
@@ 337,4 344,4 @@ if __name__=="__main__":
"Second subcommand"
print(f"name: {name!r}, long_param: {long_param!r}")
- run()>
\ No newline at end of file
+ run()