Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions internal/commands/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,15 @@ func newTemplatesLibraryCmd() *cobra.Command {
Long: "List the account's active to-do list templates.",
RunE: func(cmd *cobra.Command, args []string) error {
app := appctx.FromContext(cmd.Context())

persistentAccount := hasPersistentAccount(app.Config)
if err := ensureAccount(cmd, app); err != nil {
return err
}
contextArgs := templateCommandContextArgs(
app.Config.ActiveProfile,
persistentAccount,
app.Config.AccountID,
)

library, err := app.Account().Templates().GetLibrary(cmd.Context())
if err != nil {
Expand All @@ -169,7 +174,7 @@ func newTemplatesLibraryCmd() *cobra.Command {
output.WithBreadcrumbs(
output.Breadcrumb{
Action: "copy",
Cmd: "basecamp templates copy <template-id> --in <project>",
Cmd: "basecamp templates copy <template-id> --in <project>" + contextArgs,
Description: "Copy a template into a project",
},
),
Expand Down
4 changes: 3 additions & 1 deletion internal/commands/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func TestTemplatesLibraryUsesSDKLibraryEndpoint(t *testing.T) {
body: templateLibraryJSON,
})
buf := captureTemplateOutput(app)
app.Config.ActiveProfile = "work profile"
app.Config.Sources = map[string]string{"account_id": string(config.SourceFlag)}

err := executeRecordingCommand(NewTemplatesCmd(), app, "library")
require.NoError(t, err)
Expand All @@ -82,7 +84,7 @@ func TestTemplatesLibraryUsesSDKLibraryEndpoint(t *testing.T) {
envelope := decodeTemplateEnvelope(t, buf)
assert.Equal(t, "1 active to-do list templates", envelope.Summary)
require.Len(t, envelope.Breadcrumbs, 1)
assert.Equal(t, "basecamp templates copy <template-id> --in <project>", envelope.Breadcrumbs[0].Cmd)
assert.Equal(t, "basecamp templates copy <template-id> --in <project> --profile 'work profile' --account 99999", envelope.Breadcrumbs[0].Cmd)
}

func TestTemplatesLibraryHumanOutputShowsCopyableID(t *testing.T) {
Expand Down