diff --git a/src/python/jw/build/cmds/CmdGetAuthInfo.py b/src/python/jw/build/cmds/CmdGetAuthInfo.py index fc7a24f0..155d35e9 100644 --- a/src/python/jw/build/cmds/CmdGetAuthInfo.py +++ b/src/python/jw/build/cmds/CmdGetAuthInfo.py @@ -19,13 +19,15 @@ class CmdGetAuthInfo(Cmd): # export parser.add_argument('--password', help='Show password', action='store_true', default=False) def _run(self, args: Namespace) -> None: + keys = ['username', 'password'] + + # --- Milk jw-build repo jw_build_dir = self.app.proj_dir('jw-build') if not os.path.isdir(jw_build_dir + '/.git'): self.app.debug(f'jw-build directory is not a Git repo: {jw_build_dir}') return remotes = run_cmd(['git', '-C', jw_build_dir, 'remote', '-v']) result: dict[str, str] = {} - keys = ['username', 'password'] for line in remotes.split('\n'): if re.match(r'^\s*$', line): continue @@ -35,11 +37,14 @@ class CmdGetAuthInfo(Cmd): # export for key in keys: result[key] = getattr(parsed, key) break - for key in keys: - if key in result and getattr(args, key, None) == True: - if key is None: - continue - if args.only_values: - print(result[key]) - continue - print(f'{key}="{result[key]}"') + + # --- Print results + for key, val in result.items(): + if getattr(args, key, None) != True: + continue + if val is None: + continue + if args.only_values: + print(val) + continue + print(f'{key}="{val}"')