Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 66f1c31

Browse files
Copilotmatifali
andcommitted
Add usage examples to 'coder exp task create' help text
Co-authored-by: matifali <[email protected]>
1 parent 0583cd2 commit 66f1c31

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

cli/exp_task_create.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ func (r *RootCmd) taskCreate() *serpent.Command {
2828
cmd := &serpent.Command{
2929
Use: "create [input]",
3030
Short: "Create an experimental task",
31+
Long: FormatExamples(
32+
Example{
33+
Description: "Create a task with all flags specified",
34+
Command: "coder exp task create --input \"Refactor CLI auth to use OAuth flow\" --template coder --org coder",
35+
},
36+
Example{
37+
Description: "Create a task with a preset",
38+
Command: "coder exp task create --input \"Add new API endpoint\" --template coder --preset backend",
39+
},
40+
),
3141
Middleware: serpent.Chain(
3242
serpent.RequireRangeArgs(0, 1),
3343
r.InitClient(client),

cli/exp_task_create_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,26 @@ func TestTaskCreate(t *testing.T) {
334334
})
335335
}
336336
}
337+
338+
func TestTaskCreateHelp(t *testing.T) {
339+
t.Parallel()
340+
341+
ctx := testutil.Context(t, testutil.WaitShort)
342+
343+
inv, _ := clitest.New(t, "exp", "task", "create", "--help")
344+
var sb strings.Builder
345+
inv.Stdout = &sb
346+
inv.Stderr = &sb
347+
348+
err := inv.WithContext(ctx).Run()
349+
assert.NoError(t, err)
350+
351+
output := sb.String()
352+
// Verify that the examples are present in the help output
353+
assert.Contains(t, output, "Create a task with all flags specified")
354+
assert.Contains(t, output, "coder exp task create --input \"Refactor CLI auth to use OAuth flow\"")
355+
assert.Contains(t, output, "--template coder --org coder")
356+
assert.Contains(t, output, "Create a task with a preset")
357+
assert.Contains(t, output, "coder exp task create --input \"Add new API endpoint\"")
358+
assert.Contains(t, output, "--preset backend")
359+
}

0 commit comments

Comments
 (0)