diff options
author | Teddy Wing | 2023-11-14 01:30:23 +0100 |
---|---|---|
committer | Teddy Wing | 2023-11-14 01:34:25 +0100 |
commit | 8d8fa84f4f336f7a2e43acf7ca0c417299df8f8b (patch) | |
tree | 7b830e8f67f73306a1a717d009ff697e671ecbfb /cmd | |
parent | 1e4dd35a450bddbb519fc54b52f9486627075e9c (diff) | |
download | swextreload-8d8fa84f4f336f7a2e43acf7ca0c417299df8f8b.tar.bz2 |
main: Add basic command line argument parsing
Found Claw from a search for "argument parser" on https://godocs.io. I
did a quick comparison with a few other argument parsing libraries I
found in a GitHub search:
* https://github.com/alexflint/go-arg
* https://github.com/docopt/docopt.go
* https://github.com/fred1268/go-clap
Claw ended up being the most straightforward to me.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/swextreload/main.go | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/cmd/swextreload/main.go b/cmd/swextreload/main.go index 0d111f8..b1702f6 100644 --- a/cmd/swextreload/main.go +++ b/cmd/swextreload/main.go @@ -3,11 +3,49 @@ package main import ( "log" + "git.sr.ht/~liliace/claw" swextreload "gopkg.teddywing.com/swextreload/internal" ) func main() { - err := swextreload.Reload( + args, err := claw.Parse(&claw.Options{ + Name: "swextreload", + Description: "Reload Google Chrome extensions.", + Flags: []claw.Flag{ + { + LongName: "socket-url", + Type: "string", + Description: "DevTools protocol WebSocket URL", + }, + { + LongName: "reload-current-tab", + Type: "bool", + Description: "pass this to reload the active Chrome tab", + }, + { + LongName: "version", + ShortName: 'V', + Type: "bool", + Description: "show the program version", + }, + }, + Positionals: []claw.Positional{ + { + Name: "extension_id", + Type: "string", + Repeating: true, + Description: "extensions to reload", + }, + }, + }) + if err != nil { + log.Fatal(err) + } + + log.Printf("args: %#v", args) + return + + err = swextreload.Reload( "ws://127.0.0.1:55755/devtools/browser/4536efdf-6ddf-40b6-9a16-258a1935d866", "imcibeelfmccdpnnlemllnepgbfdbkgo", true, |