mirror of
https://github.com/danieldemus/pyp2spec.git
synced 2026-07-29 05:34:22 +02:00
30 lines
669 B
Python
30 lines
669 B
Python
import click
|
|
import tomli_w
|
|
|
|
|
|
def write_config(contents, output=None):
|
|
"""Write config file to a given destination.
|
|
If none is provided, save it to current directory with package name as file name.
|
|
"""
|
|
if output:
|
|
dest = output
|
|
else:
|
|
# TODO: name must reflect the package
|
|
dest = "./pyp2spec_test.conf"
|
|
with open(dest, "wb") as f:
|
|
tomli_w.dump(contents, f)
|
|
return dest
|
|
|
|
|
|
@click.command()
|
|
@click.option(
|
|
"--output", "-o",
|
|
help="Provide custom output for configuration file",
|
|
)
|
|
def main(output):
|
|
contents = {"test": [1, 2, 4]}
|
|
write_config(contents, output)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |