|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +"""CLI tool to retrieve information about Dependabot issues and produces Vulnerability report. |
| 4 | +
|
| 5 | +Rretrieves Dependabot issues, analyses issues, generates graphs, and generates |
| 6 | +HTML page with Vulnerability report. Is is also possible to compare two |
| 7 | +repositories. |
| 8 | +""" |
| 9 | + |
| 10 | +from argparse import ArgumentParser |
| 11 | + |
| 12 | + |
| 13 | +def create_argument_parser() -> ArgumentParser: |
| 14 | + """Create and configure argument parser object. |
| 15 | +
|
| 16 | + The parser includes the following options: |
| 17 | +
|
| 18 | + Returns: |
| 19 | + Configured ArgumentParser for parsing the command line options. |
| 20 | + """ |
| 21 | + parser = ArgumentParser(description="Vulnerability report tool") |
| 22 | + |
| 23 | + parser.add_argument( |
| 24 | + "-v", |
| 25 | + "--verbose", |
| 26 | + dest="verbose", |
| 27 | + help="make it verbose", |
| 28 | + action="store_true", |
| 29 | + default=False, |
| 30 | + ) |
| 31 | + |
| 32 | + parser.add_argument( |
| 33 | + "--organization", |
| 34 | + default="", |
| 35 | + help="GitHub organization.", |
| 36 | + required=True, |
| 37 | + ) |
| 38 | + |
| 39 | + parser.add_argument( |
| 40 | + "--repository", |
| 41 | + default="", |
| 42 | + help="GitHub repository.", |
| 43 | + required=True, |
| 44 | + ) |
| 45 | + |
| 46 | + parser.add_argument( |
| 47 | + "-r", |
| 48 | + "--retrieve-issues", |
| 49 | + default=True, |
| 50 | + help="Retrieve issues", |
| 51 | + ) |
| 52 | + |
| 53 | + parser.add_argument( |
| 54 | + "-g", |
| 55 | + "--generate-graphs", |
| 56 | + default=True, |
| 57 | + help="Generate graphs with vulnerabilities info", |
| 58 | + ) |
| 59 | + |
| 60 | + parser.add_argument( |
| 61 | + "-p", |
| 62 | + "--generate-page", |
| 63 | + default=True, |
| 64 | + help="Generate page with vulnerabilities info", |
| 65 | + ) |
| 66 | + |
| 67 | + parser.add_argument( |
| 68 | + "-c", |
| 69 | + "--comparison", |
| 70 | + default=False, |
| 71 | + help="Compare two repositories and generate comparison report. " |
| 72 | + "Need to be used with --data1 and --data2 options", |
| 73 | + ) |
| 74 | + |
| 75 | + return parser |
| 76 | + |
| 77 | + |
| 78 | +def main() -> int: |
| 79 | + """ |
| 80 | + CLI entry point that retrieves Dependabot issues and produces Vulnerability report. |
| 81 | +
|
| 82 | + Parses command-line arguments, retrieves Dependabot issues, analyses issues, generates |
| 83 | + graphs, and generates HTML page with Vulnerability report. Is is also possible to |
| 84 | + compare two repositories. |
| 85 | +
|
| 86 | + Error diagnostics are printed to stderr. |
| 87 | +
|
| 88 | + Usage: |
| 89 | +
|
| 90 | + Returns: |
| 91 | + int: Exit code where |
| 92 | + `0` indicates success, |
| 93 | + `1` indicates any failure |
| 94 | + """ |
| 95 | + parser = create_argument_parser() |
| 96 | + args = parser.parse_args() |
| 97 | + |
| 98 | + print(args) |
| 99 | + return 0 |
| 100 | + |
| 101 | + |
| 102 | +if __name__ == "__main__": |
| 103 | + raise SystemExit(main()) |
0 commit comments