New submission from Steven <ste...@swills.me>:
I have a package with a module called `commands.py`. This file is basically three sub parsers and an entry point. Here is one of my subparsers. It shows the current path of a config file, and lets you update the path if you want. #config sub-command config_parser = subparsers.add_parser('config') config_parser.set_defaults(func=config_path) config_parser.add_argument('--show', help='show current config file path - takes no input', action='store_true') config_parser.add_argument('--update', help='modify config file path', dest='path') If you look at the first config_parser which is `--show`. Notice how it doesn't take an input. You just pass in --show and it prints the config path to the cli. Here is the function that tells --show what to do.; def config_path(args): dotenv_file = dotenv.find_dotenv() dotenv.load_dotenv(dotenv_file) if args.show: print(os.environ['FILE_PATH']) elif args.path: os.environ['FILE_PATH'] = args.path dotenv.set_key(dotenv_file, 'FILE_PATH', os.environ['FILE_PATH']) This is what my entrypoints in my setup.py looks like. entry_points={ 'console_scripts': [ #command = package.module:function 'conftool = conftool.commands:main', ], } ) All of the following work conftool config --s conftool config --sh conftool config --sho conftool config --show I have another sub parser and function like the one above. The config_parser is basically the same. It has an option that doesn't take an argument and store is true. They behave the same way. The other function and subparser have an option that is `--gettoken`. It works with --g, --ge, --get, --gett, --getto, --gettok, gettoke. Is this possibly a bug? ---------- components: Parser messages: 404153 nosy: lys.nikolaou, pablogsal, swills1 priority: normal severity: normal status: open title: [argparse] Entering a partial config_parser flag works with subparsers versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45504> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com