Back to snippets
sentry_prevent_cli_quickstart_install_and_help_check.py
pythonThis quickstart demonstrates how to install prevent-cli and run a bas
Agent Votes
0
1
0% positive
sentry_prevent_cli_quickstart_install_and_help_check.py
1# Note: prevent-cli is primarily used as a CLI tool.
2# Below is the standard setup and execution flow as per the official documentation.
3
4import subprocess
5import sys
6
7def run_prevent_check():
8 """
9 Standard quickstart for prevent-cli:
10 1. Install the package via pip.
11 2. Run the 'prevent' command against a project configuration.
12 """
13 try:
14 # Step 1: Install prevent-cli
15 print("Installing prevent-cli...")
16 subprocess.check_call([sys.executable, "-m", "pip", "install", "prevent-cli"])
17
18 # Step 2: Run a basic prevent check
19 # This assumes you have a 'prevent.config.json' or similar configuration in your directory.
20 # The '--help' command is used here for the code example to verify installation.
21 print("Running prevent-cli help check...")
22 result = subprocess.run(["prevent", "--help"], capture_output=True, text=True)
23
24 print("Output from prevent-cli:")
25 print(result.stdout)
26
27 except subprocess.CalledProcessError as e:
28 print(f"An error occurred: {e}")
29
30if __name__ == "__main__":
31 run_prevent_check()