Skip to content

Commit

Permalink
Adds -i and ability to use WPA_CLI_INTERFACE to choose an interface
Browse files Browse the repository at this point in the history
  • Loading branch information
bougyman committed Jun 9, 2017
1 parent fbc0700 commit b3fcf1f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions wifish
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ cli() { # {{{ # Wrapper for wpa_cli
fi
return
fi # }}}
${wpa_cli} "$@"
if [ ! -z "$WPA_CLI_INTERFACE" ]; then
${wpa_cli} -i $WPA_CLI_INTERFACE "$@"
else
${wpa_cli} "$@"
fi


} # }}}

Expand Down Expand Up @@ -320,8 +325,10 @@ usage() { # {{{ # Usage (redundant comment)
cat <<-HERE
$0 [options] COMMAND [arguments]
Options:
-i INTERFACE The wifi interface to use
-h This Help
Commands:
list List Available APs
connect <SSID> Connect to an AP
Expand All @@ -335,11 +342,18 @@ $0 [options] COMMAND [arguments]
$0 m
Default Command (run when called with no arguments): $WIFISH_DEFAULT
ENVIRONMENT:
WPA_CLI_INTERFACE may be set to use a specific interface to avoid using -i <interface>
HERE

} # }}}

while getopts ":h" opt; do # {{{ # Option Parsing
while getopts ":h:i:" opt; do # {{{ # Option Parsing
case $opt in
i) WPA_CLI_INTERFACE=$OPTARG
shift $((OPTIND-1))
;;
\?) echo "Invalid Option: -$OPTARG" >&2
usage
exit 1
Expand All @@ -348,7 +362,7 @@ while getopts ":h" opt; do # {{{ # Option Parsing
usage
exit 1
;;
h) usage
h) usage
exit
;;
esac
Expand Down

0 comments on commit b3fcf1f

Please sign in to comment.