Added flag parsing, moved Set to a subcommand.
parent
557558cc88
commit
03bc2516f0
13
main.go
13
main.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"flag"
|
||||||
"path"
|
"path"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
@ -11,6 +12,18 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
switch flag.Arg(0) {
|
||||||
|
case "set":
|
||||||
|
SetVenture(flag.Args()[1:])
|
||||||
|
default:
|
||||||
|
fmt.Printf("Usage:\n\t%v set\n", os.Args[0])
|
||||||
|
flag.PrintDefaults()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetVenture sets the curent user's venture, either by reading the value from the command line or by prompting the user to input it interactively.
|
||||||
|
func SetVenture(args []string) {
|
||||||
curUser, err := user.Current()
|
curUser, err := user.Current()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
Loading…
Reference in New Issue