Skip to content

Commit

Permalink
Make local output configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
charlieegan3 committed Sep 8, 2021
1 parent c276544 commit b02e7e3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}

0 comments on commit b02e7e3

Please # to comment.