Fix completions and config

pull/7/head
Micke Nordin 2 years ago
parent 149dc17019
commit b866a713a2
Signed by: micke
GPG Key ID: 0DA0A7A5708FE257

@ -39,7 +39,7 @@ options:
For bash: add this to .bashrc For bash: add this to .bashrc
``` ```
eval "$(knotctl complete)" source <(knotctl complete)
``` ```
For fish, run: For fish, run:
``` ```
@ -47,11 +47,13 @@ knotctl complete --shell fish > ~/.config/fish/completions/knotctl.fish
``` ```
For tcsh: add this to .cshrc For tcsh: add this to .cshrc
``` ```
eval "$(knotctl complete --shell tcsh)" complete "knotctl" 'p@*@`python-argcomplete-tcsh "knotctl"`@' ;
``` ```
For zsh: add this to .zshrc For zsh: add this to .zshrc
``` ```
eval "$(autoload -U bashcompinit; bashcompinit; scripts/knotctl complete)" autoload -U bashcompinit
bashcompinit
source <(knotctl complete)
``` ```
### CONFIG ### CONFIG
``` ```

@ -70,8 +70,7 @@ def run_complete(shell: Union[None, str]):
elif shell == "fish": elif shell == "fish":
os.system("register-python-argcomplete --shell fish knotctl") os.system("register-python-argcomplete --shell fish knotctl")
elif shell == "tcsh": elif shell == "tcsh":
os.system("register-python-argcomplete --shell tcsh knotctl", os.system("register-python-argcomplete --shell tcsh knotctl")
shell=True)
def run_config( def run_config(
@ -214,8 +213,11 @@ def main() -> int:
if not isdir(config_basepath): if not isdir(config_basepath):
mkdir(config_basepath) mkdir(config_basepath)
if args.command == "config":
run_config(args.baseurl, args.username, args.password)
return 0
if not isfile(config_filename): if not isfile(config_filename):
if args.command != "config":
print("You need to configure knotctl before proceeding") print("You need to configure knotctl before proceeding")
run_config(config_filename) run_config(config_filename)
@ -241,8 +243,6 @@ def main() -> int:
url = setup_url(baseurl, args.data, args.name, args.rtype, ttl, args.zone) url = setup_url(baseurl, args.data, args.name, args.rtype, ttl, args.zone)
if args.command == "add": if args.command == "add":
run_add(url, args.json, headers) run_add(url, args.json, headers)
elif args.command == "config":
run_config(args.baseurl, args.username, args.password)
elif args.command == "delete": elif args.command == "delete":
run_delete(url, args.json, headers) run_delete(url, args.json, headers)
elif args.command == "list": elif args.command == "list":

Loading…
Cancel
Save