aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMantas Mikulėnas <grawity@gmail.com>2019-05-06 12:02:14 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-06 14:20:55 +0200
commitf487c49eaeb34d45d9a873ca8cc1757bcf7020d7 (patch)
tree645172d3d634c747451232a8bc5f05b6ef496ce7
parent0bcbd9d6426af8bffbe0e92a5c9573f32e4b9834 (diff)
downloadusbutils-f487c49eaeb34d45d9a873ca8cc1757bcf7020d7.tar.gz
lsusb.py: support long options
Signed-off-by: Mantas Mikulėnas <grawity@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--lsusb.py.in48
1 files 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: