Skip to content

Commit

Permalink
entries: added dummy create command with flags
Browse files Browse the repository at this point in the history
  • Loading branch information
phiros committed Apr 3, 2019
1 parent b2c7fb4 commit d9db780
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions cmd/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,31 @@ import (
)

var (
listTo string
listFrom string
listOrder string
listTo string
listFrom string
listOrder string
createDate string
createDuration time.Duration
createNote string
)

func init() {
defaultTo := time.Now()
defaultFrom := defaultTo.AddDate(0, 0, -7)
entriesListCommand.Flags().StringVarP(&listTo, "to", "t", defaultTo.Format("2006-01-02"), "list only entries until date (in YYYY-MM-DD format)")
now := time.Now()
defaultFrom := now.AddDate(0, 0, -7)
defaultDuration, err := time.ParseDuration("0m")
if err != nil {
panic(err)
}
// list
entriesListCommand.Flags().StringVarP(&listTo, "to", "t", now.Format("2006-01-02"), "list only entries until date (in YYYY-MM-DD format)")
entriesListCommand.Flags().StringVarP(&listFrom, "from", "f", defaultFrom.Format("2006-01-02"), "list only entries starting at date (in YYYY-MM-DD format)")
entriesListCommand.Flags().StringVarP(&listOrder, "order", "o", "asc", "list only entries starting at date (in YYYY-MM-DD format)")
entriesCommand.AddCommand(entriesListCommand)
// flags for create
entriesCreateCommand.Flags().StringVarP(&createDate, "date", "D", now.Format("2006-01-02"), "day for which to create entry (in YYYY-MM-DD format)")
entriesCreateCommand.Flags().DurationVarP(&createDuration, "duration", "d", defaultDuration, "duration of entry (format examples: '1h15m' or '300m' or '6h')")
entriesCreateCommand.Flags().StringVarP(&createNote, "note", "n", "", "a note describing what was worked on")
entriesCommand.AddCommand(entriesCreateCommand)
rootCmd.AddCommand(entriesCommand)
}

Expand Down Expand Up @@ -70,3 +83,11 @@ var entriesListCommand = &cobra.Command{
t.Print()
},
}

var entriesCreateCommand = &cobra.Command{
Use: "create",
Short: "create time entries",
Run: func(cmd *cobra.Command, args []string) {

},
}

0 comments on commit d9db780

Please sign in to comment.