From b0c58a529d7234777c4b1e7056b9a4cfb0b801bc Mon Sep 17 00:00:00 2001 From: CarterPerez-dev Date: Wed, 28 Jan 2026 14:52:46 -0500 Subject: [PATCH] add angela init command to scaffold pyproject.toml with config --- .../internal/cli/update.go | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/PROJECTS/simple-vulnerability-scanner/internal/cli/update.go b/PROJECTS/simple-vulnerability-scanner/internal/cli/update.go index 9c9e9044..bb6f887f 100644 --- a/PROJECTS/simple-vulnerability-scanner/internal/cli/update.go +++ b/PROJECTS/simple-vulnerability-scanner/internal/cli/update.go @@ -60,6 +60,7 @@ latest stable versions, and checks for known CVEs using OSV.dev.`, ) root.AddCommand( + newInitCmd(), newUpdateCmd(), newCheckCmd(), newScanCmd(), @@ -72,6 +73,55 @@ latest stable versions, and checks for known CVEs using OSV.dev.`, } } +const pyprojectTemplate = `[project] +name = "%s" +version = "0.1.0" +description = "" +requires-python = ">=3.13" +dependencies = [] + +[tool.angela] +# Minimum severity to report (critical, high, moderate, low) +# min-severity = "moderate" + +# Dependencies to skip during updates +# ignore = [] + +# Vulnerability IDs to suppress (accepted risk) +# ignore-vulns = [] +` + +func newInitCmd() *cobra.Command { + return &cobra.Command{ + Use: "init", + Short: "Create a new pyproject.toml with angela configuration", + RunE: func(_ *cobra.Command, _ []string) error { + return runInit() + }, + } +} + +func runInit() error { + if _, err := os.Stat("pyproject.toml"); err == nil { + return fmt.Errorf("pyproject.toml already exists") + } + + dir, err := os.Getwd() + if err != nil { + return fmt.Errorf("get working directory: %w", err) + } + + name := filepath.Base(dir) + content := fmt.Sprintf(pyprojectTemplate, name) + + if err := os.WriteFile("pyproject.toml", []byte(content), 0o644); err != nil { //nolint:gosec + return fmt.Errorf("write pyproject.toml: %w", err) + } + + fmt.Printf("\n %s pyproject.toml\n\n", greenBold("Created")) + return nil +} + func newUpdateCmd() *cobra.Command { f := &updateFlags{}