From 2bef7d65c46d4bd39ab92c6a8f8a406586a37cd4 Mon Sep 17 00:00:00 2001 From: Alex Cameron Date: Tue, 7 Dec 2021 02:04:01 +1100 Subject: [PATCH] _cli: Create --verbose flag (#185) * _cli: Create --verbose flag * README: Update help text * CHANGELOG: Add changelog entry for `--verbose` flag * bug_report: encourage people to use the `--verbose` flag Co-authored-by: William Woodruff Co-authored-by: William Woodruff --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- CHANGELOG.md | 6 ++++++ README.md | 5 ++++- pip_audit/_cli.py | 11 +++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 1f3cffed..0183cacd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -32,7 +32,7 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. -Similarly, if applicable and possible, re-run the command with `PIP_AUDIT_LOGLEVEL=debug` exported, +Similarly, if applicable and possible, re-run the command with `--verbose`, and paste the logs in the code block below: ``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 9035293c..3ef0abe1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,12 @@ All versions prior to 0.0.9 are untracked. `pip-audit` entrypoint ([#173](https://github.com/trailofbits/pip-audit/pull/173)) +* CLI: The `--verbose` flag has been added, allowing users to receive more + more verbose output from `pip-audit`. Supplying the `--verbose` flag + overrides the `PIP_AUDIT_LOGLEVEL` environment variable and is equivalent to + setting it to `debug` + ([#185](https://github.com/trailofbits/pip-audit/pull/185)) + ### Changed * CLI: `pip-audit` now clears its spinner bar from the terminal upon diff --git a/README.md b/README.md index 322aa553..3b69d4ec 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ python -m pip_audit --help usage: pip-audit [-h] [-V] [-l] [-r REQUIREMENTS] [-f FORMAT] [-s SERVICE] [-d] [-S] [--desc [{on,off,auto}]] [--cache-dir CACHE_DIR] [--progress-spinner {on,off}] [--timeout TIMEOUT] - [--path PATHS] + [--path PATHS] [-v] audit the Python environment for dependencies with known vulnerabilities @@ -73,6 +73,9 @@ optional arguments: --path PATHS restrict to the specified installation path for auditing packages; this option can be used multiple times (default: []) + -v, --verbose give more output; this setting overrides the + `PIP_AUDIT_LOGLEVEL` variable and is equivalent to + setting it to `debug` (default: False) ``` diff --git a/pip_audit/_cli.py b/pip_audit/_cli.py index a54b18a8..83aa251b 100644 --- a/pip_audit/_cli.py +++ b/pip_audit/_cli.py @@ -226,8 +226,19 @@ def audit() -> None: help="restrict to the specified installation path for auditing packages; " "this option can be used multiple times", ) + parser.add_argument( + "-v", + "--verbose", + dest="verbose", + action="store_true", + help="give more output; this setting overrides the `PIP_AUDIT_LOGLEVEL` variable and is " + "equivalent to setting it to `debug`", + ) args = parser.parse_args() + if args.verbose: + logging.root.setLevel("DEBUG") + logger.debug(f"parsed arguments: {args}") service = args.vulnerability_service.to_service(args.timeout, args.cache_dir)