diff --git a/cli/templatepresets.go b/cli/templatepresets.go new file mode 100644 index 0000000000000..ab0d49725b99a --- /dev/null +++ b/cli/templatepresets.go @@ -0,0 +1,168 @@ +package cli + +import ( + "fmt" + "strconv" + "strings" + + "golang.org/x/xerrors" + + "github.com/coder/coder/v2/cli/cliui" + "github.com/coder/coder/v2/codersdk" + "github.com/coder/serpent" +) + +func (r *RootCmd) templatePresets() *serpent.Command { + cmd := &serpent.Command{ + Use: "presets", + Short: "Manage presets of the specified template", + Aliases: []string{"preset"}, + Long: FormatExamples( + Example{ + Description: "List presets for the active version of a template", + Command: "coder templates presets list my-template", + }, + Example{ + Description: "List presets for a specific version of a template", + Command: "coder templates presets list my-template --template-version my-template-version", + }, + ), + Handler: func(inv *serpent.Invocation) error { + return inv.Command.HelpHandler(inv) + }, + Children: []*serpent.Command{ + r.templatePresetsList(), + }, + } + + return cmd +} + +func (r *RootCmd) templatePresetsList() *serpent.Command { + defaultColumns := []string{ + "name", + "parameters", + "default", + "desired prebuild instances", + } + formatter := cliui.NewOutputFormatter( + cliui.TableFormat([]templatePresetRow{}, defaultColumns), + cliui.JSONFormat(), + ) + client := new(codersdk.Client) + orgContext := NewOrganizationContext() + + var templateVersion string + + cmd := &serpent.Command{ + Use: "list