Skip to content

Commit

Permalink
Merge pull request #309 from jxdv/update-exit-code
Browse files Browse the repository at this point in the history
cli: update err msg and exit code
  • Loading branch information
d-niu authored Mar 4, 2024
2 parents d464501 + e01cdf9 commit e49bf32
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions guarddog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _get_rule_param(rules, exclude_rules, ecosystem):

if len(rules) > 0:
print("--rules and --exclude-rules cannot be used together")
exit(1)
sys.exit(1)

return rule_param

Expand Down Expand Up @@ -192,7 +192,7 @@ def _scan(identifier, version, rules, exclude_rules, output_format, exit_non_zer
scanner = cast(Optional[PackageScanner], get_scanner(ecosystem, False))
if scanner is None:
sys.stderr.write(f"Command scan is not supported for ecosystem {ecosystem}")
exit(1)
sys.exit(1)
results = []
if is_local_target(identifier):
log.debug(f"Considering that '{identifier}' is a local target, scanning filesystem")
Expand All @@ -207,9 +207,8 @@ def _scan(identifier, version, rules, exclude_rules, output_format, exit_non_zer
try:
results.append({'package': identifier} | scanner.scan_remote(identifier, version, rule_param))
except Exception as e:
sys.stderr.write("\n")
sys.stderr.write(str(e))
sys.exit()
sys.stderr.write(f"\nError '{e}' occurred while scanning remote package.")
sys.exit(1)

if output_format == "json":
import json as js
Expand Down

0 comments on commit e49bf32

Please sign in to comment.