Skip to content

Commit

Permalink
Fix scan as default when there are options passed
Browse files Browse the repository at this point in the history
Previously, if you ran `wifi` by itself, it would run the scan command,
but if you ran `wifi -i wlp3s0`, it would throw an error. This fixes the
argument parsing to default to the scan command even when there are
options passed in.
  • Loading branch information
rockymeza committed Mar 12, 2016
1 parent a0485f9 commit 266a3c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Changelog

- Make the wifi command name configurable (#55 - thanks yourealwaysbe)
- Add a __main__.py so that wifi can be invoked using python -mwifi
- Fix argument parsing so that scan is the default argument even with options passed

0.3.8
^^^^^
Expand Down
10 changes: 3 additions & 7 deletions wifi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,16 @@ def autocomplete(position, wordlist, subparsers):

def main():
parser, subparsers = arg_parser()

if len(sys.argv) == 1:
argv = ['scan']
else:
argv = sys.argv[1:]

argv = sys.argv[1:]
args = parser.parse_args(argv)

try:
if 'WIFI_AUTOCOMPLETE' in os.environ:
autocomplete(int(os.environ['COMP_CWORD']),
os.environ['COMP_WORDS'].split(), subparsers)
else:
args.func(args)
command = getattr(args, 'func', scan_command)
command(args)
except (AssertionError, InterfaceError) as e:
sys.stderr.write("Error: ")
sys.exit(e)

0 comments on commit 266a3c7

Please sign in to comment.