From fb6800c294d24412adf4c034e8edb1912a55ae20 Mon Sep 17 00:00:00 2001 From: Brona Date: Mon, 19 Aug 2024 17:52:23 +0200 Subject: [PATCH] Fix --color option parsing #21 --- src/bridge.py | 9 +++++---- src/ip.py | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/bridge.py b/src/bridge.py index b950e9f..1d9b844 100755 --- a/src/bridge.py +++ b/src/bridge.py @@ -97,7 +97,7 @@ def parse_ifconfig(res): def do_help(argv=None, json_print=None, pretty_json=None): perror("Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }") perror("where OBJECT := { link }") - perror(" OPTIONS := { -V[ersion] | -j[son] | -p[retty] }") + perror(" OPTIONS := { -V[ersion] | -j[son] | -p[retty] | -c[olor] }") perror(HELP_ADDENDUM) exit(255) @@ -202,10 +202,11 @@ def main(argv): while argv and argv[0].startswith("-"): # Turn --opt into -opt - argv[0] = argv[0][1:] if argv[0][1] == "-" else argv[0] + argv[0] = argv[0][1 if argv[0][1] == '-' else 0:] # Process options - if argv[0].startswith("-color"): - perror("iproute2mac: Color option is not implemented") + elif "-color".startswith(argv[0].split("=")[0]): + if "never" not in argv[0].split("="): + perror("iproute2mac: Color option is not implemented") argv.pop(0) elif "-json".startswith(argv[0]): json_print = True diff --git a/src/ip.py b/src/ip.py index 6e5d254..19b01aa 100755 --- a/src/ip.py +++ b/src/ip.py @@ -131,7 +131,7 @@ def link_addr_show(argv, af, json_print, pretty_json, address): def do_help(argv=None, af=None, json_print=None, pretty_json=None): perror("Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }") perror("where OBJECT := { link | addr | route | neigh }") - perror(" OPTIONS := { -V[ersion] | -j[son] | -p[retty] |") + perror(" OPTIONS := { -V[ersion] | -j[son] | -p[retty] | -c[olor] |") perror(" -4 | -6 }") perror(HELP_ADDENDUM) exit(255) @@ -669,7 +669,7 @@ def main(argv): while argv and argv[0].startswith("-"): # Turn --opt into -opt - argv[0] = argv[0][1:] if argv[0][1] == "-" else argv[0] + argv[0] = argv[0][1 if argv[0][1] == '-' else 0:] # Process options if argv[0] == "-6": af = 6 @@ -677,8 +677,9 @@ def main(argv): elif argv[0] == "-4": af = 4 argv.pop(0) - elif argv[0].startswith("-color"): - perror("iproute2mac: Color option is not implemented") + elif "-color".startswith(argv[0].split("=")[0]): + if "never" not in argv[0].split("="): + perror("iproute2mac: Color option is not implemented") argv.pop(0) elif "-json".startswith(argv[0]): json_print = True