Add config --list #8

Open
YotaYota wants to merge 2 commits from YotaYota/knotctl:add_config_list into main

@ -92,6 +92,7 @@ def run_config(
config_filename: str, config_filename: str,
context: Union[None, str] = None, context: Union[None, str] = None,
baseurl: Union[None, str] = None, baseurl: Union[None, str] = None,
list_config: bool = False,
username: Union[None, str] = None, username: Union[None, str] = None,
password: Union[None, str] = None, password: Union[None, str] = None,
): ):
@ -108,6 +109,11 @@ def run_config(
config_filename = symlink config_filename = symlink
if found: if found:
return return
if list_config:
config_data = get_config(config_filename)
config_data.pop("password", None)
output(config_data)
return
if not baseurl: if not baseurl:
needed.append("baseurl") needed.append("baseurl")
if not username: if not username:
@ -243,7 +249,6 @@ def split_url(url: str) -> dict:
"zone": zone, "zone": zone,
} }
# Entry point to program # Entry point to program
def main() -> int: def main() -> int:
description = """Manage DNS records with knot dns rest api: description = """Manage DNS records with knot dns rest api:
@ -313,6 +318,7 @@ def main() -> int:
configcmd = subparsers.add_parser("config", description=config_description) configcmd = subparsers.add_parser("config", description=config_description)
configcmd.add_argument("-b", "--baseurl") configcmd.add_argument("-b", "--baseurl")
configcmd.add_argument("-c", "--context") configcmd.add_argument("-c", "--context")
configcmd.add_argument("-l", "--list", action="store_true")
configcmd.add_argument("-p", "--password") configcmd.add_argument("-p", "--password")
configcmd.add_argument("-u", "--username") configcmd.add_argument("-u", "--username")
@ -370,8 +376,8 @@ def main() -> int:
mkdir(config_basepath) mkdir(config_basepath)
if args.command == "config": if args.command == "config":
run_config(config_filename, args.context, args.baseurl, args.username, run_config(config_filename, args.context, args.baseurl, args.list,
args.password) args.username, args.password)
return 0 return 0
if not isfile(config_filename): if not isfile(config_filename):

Loading…
Cancel
Save