Signed-off-by: Mantas Mikulėnas <grawity@xxxxxxxxx> --- lsusb.py.in | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/lsusb.py.in b/lsusb.py.in index e09b4cf..f9e273d 100644 --- a/lsusb.py.in +++ b/lsusb.py.in @@ -523,15 +523,15 @@ def usage(): print("Usage: lsusb.py [options]") print() print("Options:") - # "|-------|-------|-------|-------|-------" - print(" -h display this help") - print(" -i display interface information") - print(" -I display interface information, even for hubs") - print(" -u suppress empty hubs") - print(" -U suppress all hubs") - print(" -c use colors") - print(" -e display endpoint info") - print(" -f FILE override filename for /usr/share/usb.ids") + print(" -h, --help display this help") + print(" -i, --interfaces display interface information") + print(" -I, --hub-interfaces display interface information, even for hubs") + print(" -u, --hide-empty-hubs suppress empty hubs") + print(" -U, --hide-hubs suppress all hubs") + print(" -c, --color use colors") + print(" -e, --endpoints display endpoint info") + print(" -f FILE, --usbids-path FILE") + print(" override filename for /usr/share/usb.ids") print() print("Use lsusb.py -ciu to get a nice overview of your USB devices.") @@ -555,40 +555,52 @@ def main(argv): "main entry point" global showint, showhubint, noemptyhub, nohub global cols, usbids, showeps + + long_options = [ + "help", + "interfaces", + "hub-interfaces", + "hide-empty-hubs", + "hide-hubs", + "color", + "usbids-path=", + "endpoints", + ] + try: - (optlist, args) = getopt.gnu_getopt(argv[1:], "hiIuUwcef:", ("help",)) + (optlist, args) = getopt.gnu_getopt(argv[1:], "hiIuUwcef:", long_options) except getopt.GetoptError as exc: print("Error:", exc, file=sys.stderr) sys.exit(2) for opt in optlist: - if opt[0] == "-h" or opt[0] == "--help": + if opt[0] in {"-h", "--help"}: usage() sys.exit(0) - if opt[0] == "-i": + if opt[0] in {"-i", "--interfaces"}: showint = True continue - if opt[0] == "-I": + if opt[0] in {"-I", "--hub-interfaces"}: showint = True showhubint = True continue - if opt[0] == "-u": + if opt[0] in {"-u", "--hide-empty-hubs"}: noemptyhub = True continue - if opt[0] == "-U": + if opt[0] in {"-U", "--hide-hubs"}: noemptyhub = True nohub = True continue - if opt[0] == "-c": + if opt[0] in {"-c", "--color"}: cols = (norm, bold, red, green, amber, blue) continue if opt[0] == "-w": print("Warning: option -w is no longer supported", file=sys.stderr) continue - if opt[0] == "-f": + if opt[0] in {"-f", "--usbids-path"}: #usbids = (opt[1], *usbids) usbids = (opt[1],) continue - if opt[0] == "-e": + if opt[0] in {"-e", "--endpoints"}: showeps = True continue if len(args) > 0: -- 2.21.0