diff options
| author | Teddy Wing | 2017-06-03 19:48:09 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-03 20:53:14 +0200 | 
| commit | 43cf753e794c37a8422e42389b077f1d20edc7af (patch) | |
| tree | b5c5b64f8e339efe07b8e4b3c1d776e6da123f20 /main.go | |
| parent | fa85a708dff621e4d75f19bdbd45bba5947685c0 (diff) | |
| download | timetasker-43cf753e794c37a8422e42389b077f1d20edc7af.tar.bz2 | |
main.go: Only call `maybeWriteConfig()` when `--write-config` is given
We shouldn't automatically force writing the config file. Only do so if
the user asks for it to be done.
NOTE: there's a problem here, because `-p` is required but it shouldn't
be in this specific case.
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 22 | 
1 files changed, 15 insertions, 7 deletions
| @@ -19,13 +19,6 @@ var config Config  func main() {  	var err error -	err = maybeWriteConfig() -	if err != nil { -		fmt.Println("Could not write config file") -		fmt.Println(err) -		os.Exit(1) -	} -  	err = loadConfig()  	if err != nil {  		fmt.Println("Could not load config file") @@ -51,9 +44,24 @@ func main() {  	description := kingpin.Flag("description", "Description of work.").  		Short('m').  		String() +	 write_config_description := fmt.Sprintf( +		"Initialise a new config file template at %s", +		configFile(), +	) +	write_config := kingpin.Flag("write-config", write_config_description). +		Bool()  	kingpin.Version(VERSION)  	kingpin.Parse() +	if *write_config { +		err = maybeWriteConfig() +		if err != nil { +			fmt.Println("Could not write config file") +			fmt.Println(err) +			os.Exit(1) +		} +	} +  	// Submit time entry  	project, ok := config.Projects[*project_alias]  	if !ok { | 
