Skip to content

Commit

Permalink
Add: Introduce an error terminal for pontos-release CLI
Browse files Browse the repository at this point in the history
Print errors to stderr for errors raised in the pontos-release CLI.
  • Loading branch information
bjoernricks committed Jul 26, 2023
1 parent 434f596 commit c70b819
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pontos/release/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ def main(

if parsed_args.quiet:
term = NullTerminal()
error_terminal = NullTerminal()
logging.disable()
else:
term = RichTerminal()
error_terminal = RichTerminal(file=sys.stderr)

term.bold_info(f"pontos-release => {parsed_args.func.__name__}")

Expand All @@ -55,17 +57,17 @@ def main(
except KeyboardInterrupt:
sys.exit(1)
except GitError as e:
term.error(f'Could not run git command "{e.cmd}".')
error_terminal.error(f'Could not run git command "{e.cmd}".')
error = e.stderr if e.stderr else e.stdout
term.print(f"Output was: {error}")
error_terminal.print(f"Output was: {error}")
sys.exit(1)
except subprocess.CalledProcessError as e:
if "--passphrase" not in e.cmd:
term.error(f'Could not run command "{e.cmd}".')
error_terminal.error(f'Could not run command "{e.cmd}".')
else:
term.error("Headless signing failed.")
error_terminal.error("Headless signing failed.")

term.print(f"Error was: {e.stderr}")
error_terminal.print(f"Error was: {e.stderr}")
sys.exit(1)


Expand Down

0 comments on commit c70b819

Please sign in to comment.