milc icon indicating copy to clipboard operation
milc copied to clipboard

command-line params don't override config (again)

Open jepler opened this issue 3 years ago • 2 comments

Similar to #65, there's another scenario where command-line params do not correctly override config. I originally reported this as though it was a problem in qmk (https://github.com/qmk/qmk_firmware/pull/17624) but I think the problem may be inside milc.

Test program (hello_milc.py)

from milc import cli
import milc.subcommand.config
import pprint

@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.")
@cli.entrypoint('configuration and args')
def main(cli):
    print(f"jobs info: {cli.args.parallel=} {cli.config.general.parallel=}")
    pprint.pprint(cli.config_source)

if __name__ == '__main__':
    cli()

Out of all the various ways to specify the parallel value, -jN still doesn't work. -j N, --parallel N and --parallel=N all work.

jepler@bert:~$ python3 hello_milc.py config general.parallel=3
general.parallel: 1 -> 3
ℹ Wrote configuration to /home/jepler/.config/hello_milc/hello_milc.ini
jepler@bert:~$ python3 hello_milc.py -j 5
jobs info: cli.args.parallel=5 cli.config.general.parallel=5
{'general': {'parallel': 'argument'}}
jepler@bert:~$ python3 hello_milc.py -j5
jobs info: cli.args.parallel=5 cli.config.general.parallel=3
{'general': {'parallel': 'config_file'}}

jepler avatar Jul 11 '22 16:07 jepler

This issue has been idle for 6 months and will be closed in 2 months if the stale lable is not removed.

github-actions[bot] avatar Jun 14 '23 01:06 github-actions[bot]

repeating @skullydazed 's comment from #70:

this particular approach leads to some confusing results if you try to combine short style flags in other ways, EG using -sv instead of -s -v. I don't remember all the details now, but last I looked into it the basic problem is that I can't get the necessary information from argparse to unambiguously parse these types of flags consistently with how argparse does it.

jepler avatar Jan 27 '24 20:01 jepler