From b866a713a213120cf0f3125be1bbae2e85f8ea7a Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Tue, 25 Oct 2022 08:27:48 +0200 Subject: [PATCH] Fix completions and config --- README.md | 8 +++++--- scripts/knotctl | 14 +++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0aa9cf2..b9bfd6e 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ options: For bash: add this to .bashrc ``` -eval "$(knotctl complete)" +source <(knotctl complete) ``` For fish, run: ``` @@ -47,11 +47,13 @@ knotctl complete --shell fish > ~/.config/fish/completions/knotctl.fish ``` For tcsh: add this to .cshrc ``` -eval "$(knotctl complete --shell tcsh)" +complete "knotctl" 'p@*@`python-argcomplete-tcsh "knotctl"`@' ; ``` For zsh: add this to .zshrc ``` -eval "$(autoload -U bashcompinit; bashcompinit; scripts/knotctl complete)" +autoload -U bashcompinit +bashcompinit +source <(knotctl complete) ``` ### CONFIG ``` diff --git a/scripts/knotctl b/scripts/knotctl index 82ba424..3ae2f94 100755 --- a/scripts/knotctl +++ b/scripts/knotctl @@ -70,8 +70,7 @@ def run_complete(shell: Union[None, str]): elif shell == "fish": os.system("register-python-argcomplete --shell fish knotctl") elif shell == "tcsh": - os.system("register-python-argcomplete --shell tcsh knotctl", - shell=True) + os.system("register-python-argcomplete --shell tcsh knotctl") def run_config( @@ -214,10 +213,13 @@ def main() -> int: if not isdir(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 args.command != "config": - print("You need to configure knotctl before proceeding") - run_config(config_filename) + print("You need to configure knotctl before proceeding") + run_config(config_filename) config = get_config(config_filename) baseurl = config["baseurl"] @@ -241,8 +243,6 @@ def main() -> int: url = setup_url(baseurl, args.data, args.name, args.rtype, ttl, args.zone) if args.command == "add": run_add(url, args.json, headers) - elif args.command == "config": - run_config(args.baseurl, args.username, args.password) elif args.command == "delete": run_delete(url, args.json, headers) elif args.command == "list":