Closed mt7479 closed 6 years ago
Thanks for the suggestion, and the work on implementing it. Not being familiar with argparse, is it possible to read values from a file as well as/instead of the command line? I ask because I envision this script primarily being called by an ACME client (specifically, acme.sh, though it could be any other client), and needing to specify everything on the command line could make for a pretty unwieldy command when the cert is issued.
It could probably be done with mutual exclusive parameters and following sub parameters for the non-config file approach. However i'm not sure if it is possible to assign a custom variable name for a parameter instead of args.foo. A quick search came up with nothing.
Given as it is, it might make more sense to abandon my arguments approach and implement a config file. My motivation is to keep in sync with your upstream changes without copy/pasting my config options over and over.
Yes, and I agree with your motivation--that's why I coded my Nextcloud script to use a config file. And though I'm sure it's trivially easy to do it, I'm not quite sure how to read in a config file in Python. But I should look into it.
I'm working on a branch to use configparser to read a config file. Take a look at the use-config-file branch if you're interested. Very much a work in progress at the moment.
I wanted to suggest configparser myself and offer to look into in the weekend but you beat me to it :smile:
Looks fine to me. A small suggestion though, argparse could be used to a add an optional config file location parameter, using your deploy_config
as default but allow overriding the location if needed.
I could probably add that in a timely fashion if you see any use in it.
I've tested the changes using configparser, they work, so I've merged them. I could see, though, how the ability to specify the location of the config file could be handy--I'd be interested in taking a look at a PR for that.
Ok, I will add this today. Should I add `os.path.isfile? to check if the file path is valid and display a friendly error message ?
Opened a new pull request, let's discuss there.
I added command line options, this would also fix #5. Not sure if you are interested in having that but I thought I send you the pr anyway.