Skip to content

Commit a76d51b

Browse files
committed
(fix): interactive clone flow and --no-closing
1 parent d31cd4f commit a76d51b

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [v0.3.1] - 2020-04-01
10+
11+
## Fixed
12+
13+
- fixed `--no-closing` being ignored
14+
- interactive flow of `clone` was keeping previous time interval
15+
916
## [v0.3.0] - 2020-04-01
1017

1118
## Fixed

cmd/common.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,19 @@ func newEntry(c *api.Client, te dto.TimeEntryImpl, interactive, autoClose bool)
138138
}
139139

140140
var date *time.Time
141-
if date, err = getDateTimeParam("Start", true, whenString, convertToTime); err != nil {
141+
dateString := te.TimeInterval.Start.Format(fullTimeFormat)
142+
143+
if date, err = getDateTimeParam("Start", true, dateString, convertToTime); err != nil {
142144
return te, err
143145
}
144146
te.TimeInterval.Start = *date
145147

146-
if date, err = getDateTimeParam("End", false, whenToCloseString, convertToTime); err != nil {
148+
dateString = ""
149+
if te.TimeInterval.End != nil {
150+
dateString = te.TimeInterval.End.Format(fullTimeFormat)
151+
}
152+
153+
if date, err = getDateTimeParam("End", false, dateString, convertToTime); err != nil {
147154
return te, err
148155
}
149156
te.TimeInterval.End = date

cmd/in.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ func init() {
122122

123123
inCmd.Flags().StringP("format", "f", "", "golang text/template format to be applyed on each time entry")
124124
inCmd.Flags().BoolP("json", "j", false, "print as json")
125-
inCmd.Flags().BoolVar(&noClosing, "no-closing", false, "don't close any active time entry")
125+
inCmd.PersistentFlags().BoolVar(&noClosing, "no-closing", false, "don't close any active time entry")
126+
127+
_ = viper.BindPFlag("no-closing", inCmd.PersistentFlags().Lookup("no-closing"))
126128
}
127129

128130
func addTimeEntryFlags(cmd *cobra.Command) {

cmd/inClone.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ var inCloneCmd = &cobra.Command{
4242
viper.GetString("user.id"),
4343
c,
4444
)
45+
tec.TimeInterval.End = nil
4546

4647
if err != nil {
4748
printError(err)
@@ -129,7 +130,6 @@ func init() {
129130
rootCmd.AddCommand(inCloneCmd)
130131
inCmd.AddCommand(inCloneCmd)
131132

132-
inCloneCmd.Flags().Bool("no-closing", false, "don't close any time entry")
133133
inCloneCmd.Flags().String("when", "", "when the entry should be closed, if not informed will use current time")
134134

135135
inCloneCmd.Flags().StringP("format", "f", "", "golang text/template format to be applied on each time entry")

0 commit comments

Comments
 (0)