Open playpauseandstop opened 6 months ago
@sander76
Adding some context to my PR.
I needed to provide a CLI utilities which at same time will be called from CLI as python3 path/to/cli.py ...
and within other Python code as,
from path.to import cli
cli.main(...)
To achieving that I'm doing little dances with main function,
def main(*argv: str) -> int:
args = clipstick.parse(CliArgs, argv or sys.argv[1:])
...
and all works perfectly fine, but little perfectionist in myself want to see real tool name in help output instead of my-cli-app
, which comes from DUMMY_ENTRY_POINT
constant.
Cause of that I've come up with such PR.
Please let me know, if it seems reasonable for you or you have other ideas here.
Hi @playpauseandstop. I think have not documented this properly, but can you point your pr to my dev
branch ?
also thank for your remark about __main__.py
. I've created an issue for this: https://github.com/sander76/clipstick/issues/58
This is helpful, when list of CLI args comes not from
sys.argv
and, as result, entry point cannot be parsed fromsys.argv[0]
.This is also might be helpful for cases, when some CLI called via
python3 -m ...
andsys.argv[0]
as result contain meaningless value ofsomething/__main__.py
(however, looks like, the proper fix for that case is out of scope of current change).ps. Thanks a lot for
clipstick
library 🙏 Very appreciate your work, as it makes my life much more easier 🙇