From b02e7e3604e617c0b9cd374787106f8f98daf5e2 Mon Sep 17 00:00:00 2001 From: Charlie Egan Date: Wed, 8 Sep 2021 17:20:31 +0100 Subject: [PATCH] Make local output configurable --- cmd/sync.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/sync.go b/cmd/sync.go index fd2ad26..bdbd1b7 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -82,7 +82,12 @@ var syncCmd = &cobra.Command{ dropbox.Upload(dropboxClient, viper.GetString("dropbox.path"), []byte(vcardString)) } if syncFile { - err = os.WriteFile("out.vcard", []byte(vcardString), 0644) + outputPath := viper.GetString("local.outputPath") + if outputPath == "" { + outputPath = "output.vcard" + } + + err = os.WriteFile(outputPath, []byte(vcardString), 0644) if err != nil { log.Fatal(err) } @@ -93,6 +98,6 @@ var syncCmd = &cobra.Command{ func init() { syncCmd.Flags().BoolVar(&syncDropbox, "dropbox", false, "if set, dropbox will be synced") syncCmd.Flags().BoolVar(&syncCardDAV, "carddav", false, "if set, carddav will be synced") - syncCmd.Flags().BoolVar(&syncFile, "file", false, "if set, local will saved") + syncCmd.Flags().BoolVar(&syncFile, "file", false, "if set, local will saved at the path set in config, default: output.vcard") rootCmd.AddCommand(syncCmd) }