Skip to content

Commit

Permalink
feat: add version command
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Huck committed Aug 2, 2023
1 parent f572386 commit 59c2144
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cmd/calendarsync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ func main() {
Value: "sync.yaml",
},
&cli.StringFlag{
Name: flagStorageEncryptionKey,
Usage: "encryption string",
Required: true,
Name: flagStorageEncryptionKey,
Usage: "encryption string",
},
&cli.BoolFlag{
Name: flagClean,
Expand Down Expand Up @@ -81,11 +80,23 @@ func main() {
return nil
},
Action: Run,
Commands: []*cli.Command{
{
Name: "version",
Aliases: []string{"v"},
Usage: "shows the version of CalendarSync",
Action: func(cCtx *cli.Context) error {
fmt.Println("Version:", Version)
return nil
},
},
},
}

if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}

}

func Run(c *cli.Context) error {
Expand All @@ -95,6 +106,10 @@ func Run(c *cli.Context) error {
}
log.Info("loaded config file", "path", cfg.Path)

if len(c.String(flagStorageEncryptionKey)) == 0 {
return fmt.Errorf("flag --storage-encryption-key needs to be set")
}

startTime, err := models.TimeFromConfig(cfg.Sync.StartTime)
if err != nil {
return err
Expand Down

0 comments on commit 59c2144

Please sign in to comment.