Skip to content

Commit

Permalink
(wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucassabreu committed Jun 13, 2024
1 parent e836169 commit cb8554c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/project/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewCmdGet(
Use: "get",
Args: cmdutil.RequiredNamedArgs("project"),
ValidArgsFunction: cmdcompl.CombineSuggestionsToArgs(
cmdcomplutil.NewProjectAutoComplete(f)),
cmdcomplutil.NewProjectAutoComplete(f, f.Config())),
Short: "Get a project on a Clockify workspace",
Example: heredoc.Docf(`
$ %[1]s 621948458cb9606d934ebb1c
Expand Down
9 changes: 8 additions & 1 deletion pkg/cmd/project/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ func TestCmdGet(t *testing.T) {
args: []string{"--format={}", "-q", "-j", "p1"},
err: "flags can't be used together.*format.*json.*quiet",
factory: func(t *testing.T) cmdutil.Factory {
return mocks.NewMockFactory(t)
f := mocks.NewMockFactory(t)
f.EXPECT().Config().Return(&mocks.SimpleConfig{})

return f
},
},
{
Expand All @@ -46,6 +49,8 @@ func TestCmdGet(t *testing.T) {
args: []string{"p1"},
factory: func(t *testing.T) cmdutil.Factory {
f := mocks.NewMockFactory(t)
f.EXPECT().Config().Return(&mocks.SimpleConfig{})

f.EXPECT().GetWorkspaceID().
Return("", errors.New("workspace error"))
return f
Expand All @@ -57,6 +62,8 @@ func TestCmdGet(t *testing.T) {
args: []string{"p1"},
factory: func(t *testing.T) cmdutil.Factory {
f := mocks.NewMockFactory(t)
f.EXPECT().Config().Return(&mocks.SimpleConfig{})

f.EXPECT().GetWorkspaceID().
Return("w", nil)
f.EXPECT().Client().Return(nil, errors.New("client error"))
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/time-entry/in/in.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewCmdIn(
util.HelpMoreInfoAboutPrinting,
Args: cobra.MaximumNArgs(2),
ValidArgsFunction: cmdcompl.CombineSuggestionsToArgs(
cmdcomplutil.NewProjectAutoComplete(f)),
cmdcomplutil.NewProjectAutoComplete(f, f.Config())),
Aliases: []string{"start"},
Example: heredoc.Docf(`
# start a timer with project and description, starting now
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/time-entry/manual/manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewCmdManual(f cmdutil.Factory) *cobra.Command {
util.HelpMoreInfoAboutPrinting,
Args: cobra.MaximumNArgs(4),
ValidArgsFunction: cmdcompl.CombineSuggestionsToArgs(
cmdcomplutil.NewProjectAutoComplete(f)),
cmdcomplutil.NewProjectAutoComplete(f, f.Config())),
RunE: func(cmd *cobra.Command, args []string) error {
var whenToCloseDate time.Time
var err error
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/time-entry/report/util/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ func AddReportFlags(
cmd.Flags().StringSliceVarP(&rf.Projects, "project", "p", []string{},
"Will filter time entries using this project")
_ = cmdcompl.AddSuggestionsToFlag(cmd, "project",
cmdcomplutil.NewProjectAutoComplete(f))
cmdcomplutil.NewProjectAutoComplete(f, f.Config()))
cmd.Flags().StringVarP(&rf.Client, "client", "c", "",
"Will filter projects from this client")
_ = cmdcompl.AddSuggestionsToFlag(cmd, "project",
cmdcomplutil.NewProjectAutoComplete(f))
cmdcomplutil.NewProjectAutoComplete(f, f.Config()))
cmd.Flags().StringSliceVarP(&rf.TagIDs, "tag", "T", []string{},
"Will filter time entries using these tags")
_ = cmdcompl.AddSuggestionsToFlag(cmd, "tag",
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/time-entry/util/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func AddTimeEntryFlags(

cmd.Flags().StringP("project", "p", "", "project to use for time entry")
_ = cmdcompl.AddSuggestionsToFlag(cmd, "project",
cmdcomplutil.NewProjectAutoComplete(f))
cmdcomplutil.NewProjectAutoComplete(f, f.Config()))

cmd.Flags().StringP("description", "d", "", "time entry description")
_ = cmdcompl.AddSuggestionsToFlag(cmd, "description",
Expand Down

0 comments on commit cb8554c

Please sign in to comment.