mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
updage
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
scorecardCompact bool
|
||||
scorecardDetailed bool
|
||||
scorecardOutput string
|
||||
)
|
||||
|
||||
var scorecardCmd = &cobra.Command{
|
||||
Use: "scorecard",
|
||||
Short: "Generate Devour quality scorecards",
|
||||
Long: `Generate beautiful dark-themed scorecards showing code quality metrics.
|
||||
|
||||
Creates both compact and detailed PNG banners with:
|
||||
- Modern dark theme design
|
||||
- Glass morphism effects
|
||||
- Devour brand colors
|
||||
- Professional typography
|
||||
|
||||
Examples:
|
||||
devour scorecard # Generate both compact and detailed
|
||||
devour scorecard --compact # Generate only compact banner
|
||||
devour scorecard --detailed # Generate only detailed banner
|
||||
devour scorecard --output custom # Custom output filename`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
generateScorecards()
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(scorecardCmd)
|
||||
scorecardCmd.Flags().BoolVar(&scorecardCompact, "compact", false, "Generate compact banner only")
|
||||
scorecardCmd.Flags().BoolVar(&scorecardDetailed, "detailed", false, "Generate detailed banner only")
|
||||
scorecardCmd.Flags().StringVarP(&scorecardOutput, "output", "o", "lighthouse_scorecard", "Output filename prefix")
|
||||
}
|
||||
|
||||
func generateScorecards() {
|
||||
// Get the current working directory (project root)
|
||||
workingDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error getting working directory: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Path to the Python script relative to working directory
|
||||
pythonScriptPath := filepath.Join(workingDir, "cmd", "banner_generator", "main.py")
|
||||
|
||||
// Check if Python script exists
|
||||
if _, err := os.Stat(pythonScriptPath); os.IsNotExist(err) {
|
||||
fmt.Fprintf(os.Stderr, "Error: Python scorecard generator not found at %s\n", pythonScriptPath)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Build Python command arguments
|
||||
args := []string{pythonScriptPath}
|
||||
|
||||
if scorecardCompact {
|
||||
args = append(args, "--compact")
|
||||
} else if scorecardDetailed {
|
||||
args = append(args, "--detailed")
|
||||
}
|
||||
|
||||
if scorecardOutput != "lighthouse_scorecard" {
|
||||
args = append(args, "--output", scorecardOutput)
|
||||
}
|
||||
|
||||
// Execute Python script
|
||||
fmt.Println("🎨 Generating Devour Scorecards...")
|
||||
fmt.Printf("📂 Using generator: %s\n", pythonScriptPath)
|
||||
|
||||
cmd := exec.Command("python3", args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Dir = workingDir
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error generating scorecards: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("✅ Scorecard generation complete!")
|
||||
}
|
||||
Reference in New Issue
Block a user