Skip to content

Commit

Permalink
Merge pull request #153 from lucassabreu/feat/default
Browse files Browse the repository at this point in the history
feat: show and report defaults
  • Loading branch information
lucassabreu authored Jan 12, 2022
2 parents 8d7c574 + 7106e07 commit 28770be
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- `show` subcommand has its parameter as optional, and shows current time entry by default when the
parameter is omitted.
- `report` subcommand has its parameters as optional, and use `today` as value when none is set.
- `log in-progress` subcommand is deprecated in favor of `show`/`show current`

## [v0.28.0] - 2022-01-10

### Changed
Expand Down
7 changes: 4 additions & 3 deletions cmd/logInProgress.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import (

// logInProgressCmd represents the logInProgress command
var logInProgressCmd = &cobra.Command{
Use: "in-progress",
Aliases: []string{"current", "open", "running"},
Short: "Show time entry in progress (if any)",
Use: "in-progress",
Aliases: []string{"current", "open", "running"},
Short: "Show time entry in progress (if any)",
Deprecated: "use show current instead",
RunE: withClockifyClient(func(cmd *cobra.Command, args []string, c *api.Client) error {
te, err := c.GetHydratedTimeEntryInProgress(api.GetTimeEntryInProgressParam{
Workspace: viper.GetString(WORKSPACE),
Expand Down
20 changes: 12 additions & 8 deletions cmd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ import (

// reportCmd represents the reports command
var reportCmd = &cobra.Command{
Use: "report <start> [<end>]",
Short: `List all time entries in the date ranges and with more data (format date as 2016-01-02)`,
Args: cobra.RangeArgs(1, 2),
Use: "report [<start>] [<end>]",
Short: "List all time entries in the date ranges and with more data (format date as 2016-01-02)\n" +
"If no parameter is set, shows today's time entries",
Args: cobra.MaximumNArgs(2),
PreRunE: printMultipleTimeEntriesPreRun,
RunE: withClockifyClient(func(cmd *cobra.Command, args []string, c *api.Client) error {
start, err := time.Parse("2006-01-02", args[0])
if err != nil {
return err
RunE: withClockifyClient(func(cmd *cobra.Command, args []string, c *api.Client) (err error) {
start := time.Now()
if len(args) > 0 {
start, err = time.Parse("2006-01-02", args[0])
if err != nil {
return err
}
}
end := start

end := start
if len(args) > 1 {
end, err = time.Parse("2006-01-02", args[1])
if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions cmd/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ import (
var showCmd = &cobra.Command{
Use: "show [current|last|<time-entry-id>|^n]",
ValidArgs: []string{"current", "last"},
Args: cobra.ExactArgs(1),
Short: "Show detailed information about one time entry",
Args: cobra.MaximumNArgs(1),
Short: "Show detailed information about one time entry.\nShows current one by default",
RunE: withClockifyClient(func(cmd *cobra.Command, args []string, c *api.Client) error {
userID, err := getUserId(c)
if err != nil {
return err
}

id := "current"
if len(args) > 0 {
id = args[0]
}

tei, err := getTimeEntry(
args[0],
id,
viper.GetString(WORKSPACE),
userID,
false,
Expand Down

0 comments on commit 28770be

Please sign in to comment.