Skip to content

Commit

Permalink
make hidden SSID parameter boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn committed Aug 24, 2021
1 parent 59ee2c2 commit 45bc830
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions cmd/wifiqr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"

"github.com/reugn/wifiqr"
)

const version = "0.1.0"
const version = "0.2.0"

var (
versionParam = flag.Bool("version", false, "Show version.")

ssidParam = flag.String("ssid", "", "The name of the wireless network. You'll be prompted to enter the SSID if not set.")
keyParam = flag.String("key", "", "A pre-shared key (PSK). You'll be prompted to enter the key if not set.")
encParam = flag.String("enc", "WPA2", "The wireless network encryption protocol (WEP, WPA, WPA2).")
hiddenParam = flag.String("hidden", "false", "Hidden SSID true/false.")
hiddenParam = flag.Bool("hidden", false, "Hidden SSID.")

fileNameParam = flag.String("file", "", "A png file to write the QR Code (prints to stdout if not set).")
sizeParam = flag.Int("size", 256, "Size is both the image width and height in pixels.")
Expand All @@ -34,7 +33,7 @@ func main() {

validateArguments()

config := wifiqr.NewConfig(*ssidParam, *keyParam, *encParam, validateAndGetHidden())
config := wifiqr.NewConfig(*ssidParam, *keyParam, *encParam, *hiddenParam)
q, err := wifiqr.InitCode(config)
if err != nil {
fmt.Println(err)
Expand Down Expand Up @@ -62,15 +61,6 @@ func validateAndGetFileName() string {
return *fileNameParam
}

func validateAndGetHidden() bool {
hidden, err := strconv.ParseBool(*hiddenParam)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
return hidden
}

func validateArguments() {
if *ssidParam == "" {
fmt.Println("Enter the name of the wireless network (SSID):")
Expand Down

0 comments on commit 45bc830

Please sign in to comment.