Exclude some options from config file
ericfrederich opened this issue · 1 comments
ericfrederich commented
There may exist special options that are dangerous to put into a config file. For example --yes
or --auto-confirm
which should only be specified by CLI option not config file.
Would be nice to support an option to exclude. For example...
@click_config_file.configuration_option(excluded={"yes"})
@click.option("--out-dir", type=pathlib.Path, required=True)
@click.option("--yes", "-y", help="Auto confirmation without any prompts")
def my_command(out_dir, yes):
if out_dir.exists() and any(out_dir.iterdir()):
if not yes:
click.confirm(f"{out_dir} is not empty; do you wish to remove it?", abort=True)
else:
click.secho(f"{out_dir} is not empty; removing because you specified --yes", fg="red", bold=True)
shutil.rmtree(out_dir)
kdeldycke commented
FYI, I'm maintaining (yet another) configuration file add-on for Click
: click-extra
.
It allows for exclusion of some options as you requested.