From 03bc2516f038f5fa02039970e7b8b0aafac3ba76 Mon Sep 17 00:00:00 2001 From: Diff Date: Fri, 13 Nov 2020 03:46:00 +0000 Subject: [PATCH] Added flag parsing, moved Set to a subcommand. --- main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.go b/main.go index ba6cec0..bf3e040 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "flag" "path" "os" "os/user" @@ -11,6 +12,18 @@ import ( ) 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() if err != nil { panic(err)