Creating configuration files from scratch
It would be awesome if commands that are @click.command(cls=bob.extension.scripts.click_helper.ConfigCommand)
add an option by default that allows the user to create a new configuration file (python-file) in which the configuration options, their defaults and documentation is pasted on. Here is an example:
@hed.command(cls=ConfigCommand)
@click.option(
'--output-path',
'-o',
required=True,
default=/my/path/file.txt,
help="Path leading to the local destination of the file to be downloaded",
cls=ResourceOption)
@verbosity_option(cls=ResourceOption)
def download(output_path):
pass
Then, using --dump-config defaults.py
with the command above, the user would get on defaults.py
:
#!/usr/bin/env python
# This configuration file was generated automatically from
# `bob foo download --dump-config` on <date>
# Path leading to the local destination of the file to be downloaded
# Option: -o, --output-path
output_path = "/my/path/file.txt"
# Increase verbosity leval from 0 (only error messages)...
# Option: -v, --verbose
verbose = 3
Running this file through the command should produce the same results as running the command-line w/o any options or arguments. Options that are required should be set to None
.