Added flag parsing, moved Set to a subcommand.

main
diff 2020-11-13 03:46:00 +00:00
parent 557558cc88
commit 03bc2516f0
1 changed files with 13 additions and 0 deletions

13
main.go
View File

@ -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)