From 6e278a293a7f9dada5bc0eb6e240a512af85c83d Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 09:48:48 +0000 Subject: [PATCH] feat(dev): show workflow templates in list Co-Authored-By: Virgil --- cmd/dev/cmd_workflow.go | 6 +++++- cmd/dev/cmd_workflow_test.go | 20 ++++++++++++++++++++ locales/en.json | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cmd/dev/cmd_workflow.go b/cmd/dev/cmd_workflow.go index edbb33a..be47c9c 100644 --- a/cmd/dev/cmd_workflow.go +++ b/cmd/dev/cmd_workflow.go @@ -7,10 +7,10 @@ import ( "slices" "strings" - "forge.lthn.ai/core/cli/pkg/cli" "dappco.re/go/core/i18n" "dappco.re/go/core/io" "dappco.re/go/core/scm/repos" + "forge.lthn.ai/core/cli/pkg/cli" ) // Workflow command flags @@ -117,6 +117,10 @@ func runWorkflowList(registryPath string) error { for _, wf := range templateWorkflows { templateSet[wf] = true } + templateNames := slices.Sorted(maps.Keys(templateSet)) + if len(templateNames) > 0 { + cli.Print("%s %s\n\n", i18n.T("cmd.dev.workflow.templates"), strings.Join(templateNames, ", ")) + } // Build table headers := []string{i18n.T("cmd.dev.workflow.header.repo")} diff --git a/cmd/dev/cmd_workflow_test.go b/cmd/dev/cmd_workflow_test.go index 14250d7..55622f2 100644 --- a/cmd/dev/cmd_workflow_test.go +++ b/cmd/dev/cmd_workflow_test.go @@ -1,7 +1,9 @@ package dev import ( + "maps" "path/filepath" + "slices" "testing" "dappco.re/go/core/io" @@ -106,3 +108,21 @@ func TestFindTemplateWorkflow_NotFound(t *testing.T) { t.Errorf("Expected empty string for non-existent template, got %s", result) } } + +func TestTemplateNames_Good(t *testing.T) { + templateSet := map[string]bool{ + "z.yml": true, + "a.yml": true, + "m.yml": true, + } + + names := slices.Sorted(maps.Keys(templateSet)) + + if len(names) != 3 { + t.Fatalf("Expected 3 template names, got %d", len(names)) + } + + if names[0] != "a.yml" || names[1] != "m.yml" || names[2] != "z.yml" { + t.Fatalf("Expected sorted template names, got %v", names) + } +} diff --git a/locales/en.json b/locales/en.json index 59d9e39..d8a5f09 100644 --- a/locales/en.json +++ b/locales/en.json @@ -210,6 +210,7 @@ "skipped_count": "{{.Count}} skipped", "synced_count": "{{.Count}} synced", "would_sync_count": "{{.Count}} would sync", + "templates": "Templates", "header": { "repo": "Repo" },