Skip to content

Commit d727a98

Browse files
authored
Merge pull request #47 from lexhuismans/feature/ignore-color-option
Feature/ignore color option
2 parents 228e3e0 + 574db79 commit d727a98

1 file changed

Lines changed: 21 additions & 18 deletions

File tree

src/ip.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -732,29 +732,32 @@ def do_neigh_flush(argv, af):
732732

733733
@help_msg("do_help")
734734
def main(argv):
735-
# Detect Address family
736735
af = -1 # default / both
737-
if argv and argv[0] == "-6":
738-
af = 6
739-
argv.pop(0)
740-
elif argv and argv[0] == "-4":
741-
af = 4
742-
argv.pop(0)
743736

744-
if not argv:
745-
return False
746-
747-
if argv[0] in ["-V", "-Version"]:
748-
print("iproute2mac, v" + VERSION)
749-
exit(0)
737+
# Check all the options
738+
while argv and argv[0].startswith("-"):
739+
# Detect Address family
740+
if argv[0] == "-6":
741+
af = 6
742+
argv.pop(0)
743+
elif argv[0] == "-4":
744+
af = 4
745+
argv.pop(0)
746+
elif argv[0].startswith("-color"):
747+
perror("iproute2mac: Color option is not implemented")
748+
argv.pop(0)
749+
elif "-Version".startswith(argv[0]):
750+
print("iproute2mac, v" + VERSION)
751+
exit(0)
752+
elif "-help".startswith(argv[0]):
753+
return False
754+
else:
755+
perror('Option "{}" is unknown, try "ip help".'.format(argv[0]))
756+
exit(255)
750757

751-
if argv[0] in ["-h", "-help"]:
758+
if not argv:
752759
return False
753760

754-
if argv[0].startswith("-"):
755-
perror('Option "{}" is unknown, try "ip -help".'.format(argv[0]))
756-
exit(255)
757-
758761
for cmd, cmd_func in cmds:
759762
if cmd.startswith(argv[0]):
760763
argv.pop(0)

0 commit comments

Comments
 (0)