Skip to content

Commit

Permalink
Fix --color option parsing #21
Browse files Browse the repository at this point in the history
  • Loading branch information
brona committed Aug 19, 2024
1 parent 4170c91 commit fb6800c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -669,16 +669,17 @@ 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
argv.pop(0)
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
Expand Down

0 comments on commit fb6800c

Please sign in to comment.