Skip to content

Commit a1ce340

Browse files
Feature: Add CLI list-templates Command #31
Adds new Feature: Add CLI list-templates Command #31
1 parent 0bc16a0 commit a1ce340

10 files changed

Lines changed: 109 additions & 0 deletions

cli/devopsos.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,5 +877,44 @@ def process_first_cmd(
877877
process_first.display(section.value)
878878

879879

880+
# List of scaffold modules for dynamic template discovery
881+
_SCAFFOLD_MODULES = [
882+
scaffold_gha,
883+
scaffold_gitlab,
884+
scaffold_jenkins,
885+
scaffold_cicd,
886+
scaffold_argocd,
887+
scaffold_sre,
888+
scaffold_unittest,
889+
scaffold_devcontainer,
890+
]
891+
892+
893+
def _collect_templates():
894+
"""Collect TEMPLATE_INFO from all scaffold modules, grouped by category."""
895+
by_category = {}
896+
for mod in _SCAFFOLD_MODULES:
897+
info = getattr(mod, "TEMPLATE_INFO", None)
898+
if info:
899+
cat = info.get("category", "Other")
900+
by_category.setdefault(cat, []).append(info)
901+
return by_category
902+
903+
904+
@app.command("list")
905+
def list_templates():
906+
"""List all available scaffold templates organized by category."""
907+
templates = _collect_templates()
908+
typer.echo("\nAvailable Templates:\n")
909+
for category, items in templates.items():
910+
typer.echo(typer.style(category, bold=True))
911+
for t in items:
912+
name = t["name"].ljust(14)
913+
desc = t["description"]
914+
typer.echo(f" {name} {desc}")
915+
typer.echo()
916+
typer.echo("Run 'python -m cli.devopsos scaffold --help' for usage details.\n")
917+
918+
880919
if __name__ == "__main__":
881920
app()

cli/scaffold_argocd.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
└── image-update-automation.yaml Flux image update automation
1717
"""
1818

19+
TEMPLATE_INFO = {
20+
"name": "argocd",
21+
"category": "GitOps",
22+
"description": "ArgoCD/Flux manifests",
23+
}
24+
1925
import os
2026
import argparse
2127
import yaml

cli/scaffold_cicd.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
python -m cli.devopsos scaffold cicd [options]
1212
"""
1313

14+
TEMPLATE_INFO = {
15+
"name": "cicd",
16+
"category": "CI/CD",
17+
"description": "Combined CI/CD (GHA + Jenkins)",
18+
}
19+
1420
import os
1521
import sys
1622
import argparse

cli/scaffold_devcontainer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
└── devcontainer.env.json Tool / language selection & versions
1414
"""
1515

16+
TEMPLATE_INFO = {
17+
"name": "devcontainer",
18+
"category": "Development",
19+
"description": "VS Code dev containers",
20+
}
21+
1622
import os
1723
import argparse
1824
import json

cli/scaffold_gha.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
- Matrix build support for multiple OS/architectures
1616
"""
1717

18+
TEMPLATE_INFO = {
19+
"name": "gha",
20+
"category": "CI/CD",
21+
"description": "GitHub Actions workflows",
22+
}
23+
1824
import os
1925
import sys
2026
import argparse

cli/scaffold_gitlab.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
- Merge request pipelines and branch protection
1515
"""
1616

17+
TEMPLATE_INFO = {
18+
"name": "gitlab",
19+
"category": "CI/CD",
20+
"description": "GitLab CI pipelines",
21+
}
22+
1723
import os
1824
import sys
1925
import argparse

cli/scaffold_jenkins.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
- Support for various source control management (SCM) systems
1616
"""
1717

18+
TEMPLATE_INFO = {
19+
"name": "jenkins",
20+
"category": "CI/CD",
21+
"description": "Jenkins pipelines",
22+
}
23+
1824
import os
1925
import sys
2026
import argparse

cli/scaffold_sre.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
└── alertmanager-config.yaml Alertmanager receiver config stub
1717
"""
1818

19+
TEMPLATE_INFO = {
20+
"name": "sre",
21+
"category": "SRE",
22+
"description": "Prometheus alerts, Grafana dashboards, SLOs",
23+
}
24+
1925
import os
2026
import argparse
2127
import json

cli/scaffold_unittest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
└── sample_test.go # Go — sample unit test file
2727
"""
2828

29+
TEMPLATE_INFO = {
30+
"name": "unittest",
31+
"category": "Testing",
32+
"description": "Unit test configs (pytest, Jest, Go)",
33+
}
34+
2935
import os
3036
import sys
3137
import argparse

cli/test_cli.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,28 @@ def _strip_ansi(s):
2424

2525
# -- devopsos CLI ----------------------------------------------------------
2626

27+
def test_list_command():
28+
"""Test that list command shows all templates grouped by category."""
29+
result = _run_module("cli.devopsos", ["list"])
30+
assert result.returncode == 0
31+
out = _strip_ansi(result.stdout)
32+
assert "CI/CD" in out
33+
assert "GitOps" in out
34+
assert "SRE" in out
35+
assert "Testing" in out
36+
assert "Development" in out
37+
assert "gha" in out
38+
assert "jenkins" in out
39+
assert "argocd" in out
40+
41+
42+
def test_list_in_help():
43+
"""Test that list appears in main help."""
44+
result = _run_module("cli.devopsos", ["--help"])
45+
assert result.returncode == 0
46+
assert "list" in result.stdout
47+
48+
2749
def test_help():
2850
result = _run(["-m", "cli.devopsos", "--help"])
2951
assert result.returncode == 0

0 commit comments

Comments
 (0)