Add feature to show current context

main
Micke Nordin 2 months ago
parent fb89d01be1
commit f6915b3e4a

@ -7,7 +7,7 @@ import os
import sys
import urllib.parse
from os import environ, mkdir
from os.path import isdir, isfile, join, split
from os.path import isdir, isfile, islink, join, split
from typing import Union
from urllib.parse import urlparse
@ -139,7 +139,15 @@ def run_config(
baseurl: Union[None, str] = None,
username: Union[None, str] = None,
password: Union[None, str] = None,
current: Union[None, str] = None,
):
if current:
if os.path.islink(config_filename):
actual_path = os.readlink(config_filename)
print(actual_path.split('-')[-1])
else:
print("none")
return
config = {"baseurl": baseurl, "username": username, "password": password}
needed = []
if context:
@ -365,6 +373,7 @@ def main() -> int:
configcmd = subparsers.add_parser("config", description=config_description)
configcmd.add_argument("-b", "--baseurl")
configcmd.add_argument("-c", "--context")
configcmd.add_argument("-C", "--current", action=argparse.BooleanOptionalAction)
configcmd.add_argument("-p", "--password")
configcmd.add_argument("-u", "--username")
@ -433,7 +442,7 @@ def main() -> int:
if args.command == "config":
run_config(
config_filename, args.context, args.baseurl, args.username, args.password
config_filename, args.context, args.baseurl, args.username, args.password, args.current
)
return 0

Loading…
Cancel
Save