package cmd

import (
	"github.com/spf13/cobra"
)

var (
	scorecardPath            string
	scorecardBadgePath       string
	scorecardResetSubjective bool
	scorecardSkipSlow        bool
)

var scorecardCmd = &cobra.Command{
	Use:   "scorecard",
	Short: "Generate a scorecard badge via desloppify",
	Long: `Generate the quality scorecard badge by delegating to desloppify.

This runs a scan and writes badge output to --badge-path.
Examples:
  devour scorecard
  devour scorecard --path . --badge-path scorecard.png
  devour scorecard --reset-subjective`,
	RunE: func(cmd *cobra.Command, args []string) error {
		forward := []string{"scan", "--path", scorecardPath, "--badge-path", scorecardBadgePath}
		if scorecardResetSubjective {
			forward = append(forward, "--reset-subjective")
		}
		if scorecardSkipSlow {
			forward = append(forward, "--skip-slow")
		}
		return runDesloppifyFromCommand(cmd, forward, true)
	},
}

func init() {
	scorecardCmd.Flags().StringVar(&scorecardPath, "path", ".", "Path to scan")
	scorecardCmd.Flags().StringVar(&scorecardBadgePath, "badge-path", "scorecard.png", "Badge output path")
	scorecardCmd.Flags().BoolVar(&scorecardResetSubjective, "reset-subjective", false, "Reset subjective scores before scan")
	scorecardCmd.Flags().BoolVar(&scorecardSkipSlow, "skip-slow", false, "Skip slow detectors")
}
