OFS / opae-sdk

Open Programmable Acceleration Engine
https://ofs.github.io
BSD 3-Clause "New" or "Revised" License
259 stars 82 forks source link

Update: use argparse subparsers in pci_device #3022

Closed tswhison closed 1 year ago

tswhison commented 1 year ago

Description

Previously, pci_device used parser.parse_known_args() after adding custom parsers in each command class. These parsers were disjoint from the parser declared and referenced in main. The main parser, however, was responsible for creating the command help. The result was that the commands' options were not reflected in the help output.

Moving to argparse subparsers corrects the problem, so that all options are visible from the main parser's help printout.

Here's an example: # pci_device 0000:dc:00.0 aer mask --help usage: pci_device device-filter aer mask [-h] [-o OUTPUT] [-i INPUT] [values ...]

positional arguments: values show, print, all, off, \<int> \<int>

optional arguments: -h, --help show this help message and exit -o OUTPUT, --output OUTPUT file to store values for show/print -i INPUT, --input INPUT file to read values from

Collateral (docs, reports, design examples, case IDs):

N/A

Tests added:

Tests run:

Manual execution of all pci_device commands and manual inspection of help output.