mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 12:23:22 +00:00
Split audit.go (1349→997 lines) into focused files:
- audit_render.go: all terminal output (printSkillResult*, buildAuditSummaryLines, presentAuditResults, printAuditHelp)
- audit_policy.go: policy label/colorize helpers shared by CLI and TUI
Additional cleanups:
- Replace anonymous struct{name,path} with named auditSkillRef
- Move modeString to mode.go, pathExists to helpers.go
- Fix recountSummary missing PolicyAnalyzers preservation after dedupe
- Replace 3 hardcoded ANSI escape codes with ui.Green/ui.Gray/ui.Reset
62 lines
1.2 KiB
Go
62 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"skillshare/internal/ui"
|
|
)
|
|
|
|
type runMode int
|
|
|
|
const (
|
|
modeAuto runMode = iota
|
|
modeProject
|
|
modeGlobal
|
|
)
|
|
|
|
func parseModeArgs(args []string) (runMode, []string, error) {
|
|
mode := modeAuto
|
|
rest := make([]string, 0, len(args))
|
|
|
|
for i := 0; i < len(args); i++ {
|
|
switch args[i] {
|
|
case "--project", "-p":
|
|
if mode == modeGlobal {
|
|
return modeAuto, nil, fmt.Errorf("--project and --global are mutually exclusive")
|
|
}
|
|
mode = modeProject
|
|
case "--global", "-g":
|
|
if mode == modeProject {
|
|
return modeAuto, nil, fmt.Errorf("--project and --global are mutually exclusive")
|
|
}
|
|
mode = modeGlobal
|
|
default:
|
|
rest = append(rest, args[i])
|
|
}
|
|
}
|
|
|
|
return mode, rest, nil
|
|
}
|
|
|
|
// applyModeLabel sets ui.ModeLabel when in project mode.
|
|
// Call after mode is resolved and before any UI output.
|
|
func applyModeLabel(mode runMode) {
|
|
if mode == modeProject {
|
|
ui.ModeLabel = "project"
|
|
}
|
|
}
|
|
|
|
func modeString(mode runMode) string {
|
|
if mode == modeProject {
|
|
return "project"
|
|
}
|
|
return "global"
|
|
}
|
|
|
|
func projectConfigExists(root string) bool {
|
|
_, err := os.Stat(filepath.Join(root, ".skillshare", "config.yaml"))
|
|
return err == nil
|
|
}
|