mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
feat(ui): redesign install command with tree-style output
- Add tree structure UI (▸ → ├─ → └─) for install progress - Add SkillBox component for displaying skill details - Customize survey multi-select with cleaner icons (✓, ▸) - Unify UI across all install modes (discovery, track, subdir, direct) - Show version number in logo for install commands - Add logo to doctor and status commands - Quiet git clone output for cleaner experience
This commit is contained in:
@@ -117,9 +117,9 @@ Done. Your skills are now synced across all AI CLI tools.
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Source Directory │
|
||||
│ macOS/Linux: ~/.config/skillshare/skills/ │
|
||||
│ Windows: %USERPROFILE%\.config\skillshare\skills\ │
|
||||
│ Source Directory │
|
||||
│ macOS/Linux: ~/.config/skillshare/skills/ │
|
||||
│ Windows: %USERPROFILE%\.config\skillshare\skills\ │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│ sync
|
||||
┌───────────────┼───────────────┐
|
||||
|
||||
@@ -33,6 +33,8 @@ func (r *doctorResult) addWarning() {
|
||||
}
|
||||
|
||||
func cmdDoctor(args []string) error {
|
||||
ui.Logo(version)
|
||||
|
||||
ui.Header("Checking environment")
|
||||
result := &doctorResult{}
|
||||
|
||||
|
||||
+132
-91
@@ -11,6 +11,7 @@ import (
|
||||
"skillshare/internal/install"
|
||||
"skillshare/internal/ui"
|
||||
"skillshare/internal/validate"
|
||||
appversion "skillshare/internal/version"
|
||||
)
|
||||
|
||||
func resolveSkillFromName(skillName string, cfg *config.Config) (*install.Source, error) {
|
||||
@@ -120,44 +121,45 @@ func cmdInstall(args []string) error {
|
||||
}
|
||||
|
||||
func handleTrackedRepoInstall(source *install.Source, cfg *config.Config, opts install.InstallOptions) error {
|
||||
// Header box
|
||||
subtitle := fmt.Sprintf("Source: %s", source.Raw)
|
||||
if opts.Name != "" {
|
||||
subtitle += fmt.Sprintf("\nName override: _%s", opts.Name)
|
||||
}
|
||||
ui.HeaderBox("skillshare install --track", subtitle)
|
||||
fmt.Println()
|
||||
// Show logo with version
|
||||
ui.Logo(appversion.Version)
|
||||
|
||||
spinner := ui.StartSpinner("Cloning repository...")
|
||||
// Step 1: Show source
|
||||
ui.StepStart("Source", source.Raw)
|
||||
if opts.Name != "" {
|
||||
ui.StepContinue("Name", "_"+opts.Name)
|
||||
}
|
||||
|
||||
// Step 2: Clone with tree spinner
|
||||
treeSpinner := ui.StartTreeSpinner("Cloning repository...", false)
|
||||
|
||||
result, err := install.InstallTrackedRepo(source, cfg.Source, opts)
|
||||
if err != nil {
|
||||
spinner.Fail("Failed to install")
|
||||
treeSpinner.Fail("Failed to clone")
|
||||
return err
|
||||
}
|
||||
|
||||
// Display result
|
||||
if opts.DryRun {
|
||||
spinner.Stop()
|
||||
ui.Warning("[dry-run] %s", result.Action)
|
||||
} else {
|
||||
spinner.Success(fmt.Sprintf("Installed tracked repo: %s", result.RepoName))
|
||||
fmt.Println()
|
||||
treeSpinner.Success("Cloned")
|
||||
|
||||
// Show info box
|
||||
lines := []string{
|
||||
"",
|
||||
fmt.Sprintf(" Path: %s", result.RepoPath),
|
||||
fmt.Sprintf(" Skills: %d found", result.SkillCount),
|
||||
"",
|
||||
}
|
||||
// Step 3: Show result
|
||||
if opts.DryRun {
|
||||
ui.StepEnd("Action", result.Action)
|
||||
fmt.Println()
|
||||
ui.Warning("[dry-run] Would install tracked repo")
|
||||
} else {
|
||||
ui.StepEnd("Found", fmt.Sprintf("%d skill(s)", result.SkillCount))
|
||||
|
||||
// Show skill box
|
||||
fmt.Println()
|
||||
ui.SkillBox(result.RepoName, fmt.Sprintf("Tracked repository with %d skills", result.SkillCount), result.RepoPath)
|
||||
|
||||
// Show skill list if not too many
|
||||
if len(result.Skills) > 0 && len(result.Skills) <= 10 {
|
||||
fmt.Println()
|
||||
for _, skill := range result.Skills {
|
||||
lines = append(lines, fmt.Sprintf(" - %s", skill))
|
||||
ui.SkillBoxCompact(skill, "")
|
||||
}
|
||||
lines = append(lines, "")
|
||||
}
|
||||
ui.Box("Installed", lines...)
|
||||
}
|
||||
|
||||
// Display warnings
|
||||
@@ -176,40 +178,59 @@ func handleTrackedRepoInstall(source *install.Source, cfg *config.Config, opts i
|
||||
}
|
||||
|
||||
func handleGitDiscovery(source *install.Source, cfg *config.Config, opts install.InstallOptions) error {
|
||||
// Header box
|
||||
ui.HeaderBox("skillshare install", fmt.Sprintf("Source: %s", source.Raw))
|
||||
fmt.Println()
|
||||
// Show logo with version
|
||||
ui.Logo(appversion.Version)
|
||||
|
||||
spinner := ui.StartSpinner("Cloning repository...")
|
||||
// Step 1: Show source
|
||||
ui.StepStart("Source", source.Raw)
|
||||
|
||||
// Step 2: Clone with tree spinner animation
|
||||
treeSpinner := ui.StartTreeSpinner("Cloning repository...", false)
|
||||
|
||||
// Discover skills
|
||||
discovery, err := install.DiscoverFromGit(source)
|
||||
if err != nil {
|
||||
spinner.Fail("Failed to clone")
|
||||
treeSpinner.Fail("Failed to clone")
|
||||
return err
|
||||
}
|
||||
defer install.CleanupDiscovery(discovery)
|
||||
|
||||
treeSpinner.Success("Cloned")
|
||||
|
||||
// Step 3: Show found skills
|
||||
if len(discovery.Skills) == 0 {
|
||||
spinner.Fail("No skills found")
|
||||
ui.Warning("No skills found in repository (no SKILL.md files)")
|
||||
ui.StepEnd("Found", "No skills (no SKILL.md files)")
|
||||
return nil
|
||||
}
|
||||
|
||||
spinner.Success(fmt.Sprintf("Found %d skill(s)", len(discovery.Skills)))
|
||||
fmt.Println()
|
||||
ui.StepEnd("Found", fmt.Sprintf("%d skill(s)", len(discovery.Skills)))
|
||||
|
||||
// Single skill: show detailed box
|
||||
if len(discovery.Skills) == 1 {
|
||||
skill := discovery.Skills[0]
|
||||
loc := skill.Path
|
||||
if loc == "." {
|
||||
loc = "root"
|
||||
}
|
||||
fmt.Println()
|
||||
ui.SkillBox(skill.Name, "", loc)
|
||||
}
|
||||
|
||||
if opts.DryRun {
|
||||
// Show skill list in dry-run mode
|
||||
for _, skill := range discovery.Skills {
|
||||
ui.ListItem("info", skill.Name, skill.Path)
|
||||
if len(discovery.Skills) > 1 {
|
||||
fmt.Println()
|
||||
for _, skill := range discovery.Skills {
|
||||
ui.SkillBoxCompact(skill.Name, skill.Path)
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
ui.Warning("[dry-run] Would prompt for selection")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Prompt for selection
|
||||
fmt.Println()
|
||||
|
||||
// Prompt for selection (shows skill list in multi-select)
|
||||
selected, err := promptSkillSelection(discovery.Skills)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -220,7 +241,7 @@ func handleGitDiscovery(source *install.Source, cfg *config.Config, opts install
|
||||
return nil
|
||||
}
|
||||
|
||||
// Install selected skills
|
||||
// Install with animation
|
||||
fmt.Println()
|
||||
|
||||
type installResult struct {
|
||||
@@ -230,10 +251,13 @@ func handleGitDiscovery(source *install.Source, cfg *config.Config, opts install
|
||||
}
|
||||
results := make([]installResult, 0, len(selected))
|
||||
|
||||
spinner = ui.StartSpinner(fmt.Sprintf("Installing %d skill(s)...", len(selected)))
|
||||
installSpinner := ui.StartSpinnerWithSteps("Installing...", len(selected))
|
||||
|
||||
for i, skill := range selected {
|
||||
spinner.Update(fmt.Sprintf("Installing %s... (%d/%d)", skill.Name, i+1, len(selected)))
|
||||
installSpinner.NextStep(fmt.Sprintf("Installing %s...", skill.Name))
|
||||
if i == 0 {
|
||||
installSpinner.Update(fmt.Sprintf("Installing %s...", skill.Name))
|
||||
}
|
||||
destPath := filepath.Join(cfg.Source, skill.Name)
|
||||
|
||||
_, err := install.InstallFromDiscovery(discovery, skill, destPath, opts)
|
||||
@@ -256,20 +280,20 @@ func handleGitDiscovery(source *install.Source, cfg *config.Config, opts install
|
||||
}
|
||||
|
||||
if failed > 0 && installed == 0 {
|
||||
spinner.Fail(fmt.Sprintf("Failed to install %d skill(s)", failed))
|
||||
installSpinner.Fail(fmt.Sprintf("Failed to install %d skill(s)", failed))
|
||||
} else if failed > 0 {
|
||||
spinner.Success(fmt.Sprintf("Installed %d skill(s), %d failed", installed, failed))
|
||||
installSpinner.Success(fmt.Sprintf("Installed %d, failed %d", installed, failed))
|
||||
} else {
|
||||
spinner.Success(fmt.Sprintf("Installed %d skill(s)", installed))
|
||||
installSpinner.Success(fmt.Sprintf("Installed %d skill(s)", installed))
|
||||
}
|
||||
|
||||
// Show results
|
||||
fmt.Println()
|
||||
for _, r := range results {
|
||||
if r.success {
|
||||
ui.ListItem("success", r.skill.Name, r.message)
|
||||
ui.StepDone(r.skill.Name, "installed")
|
||||
} else {
|
||||
ui.ListItem("error", r.skill.Name, r.message)
|
||||
ui.StepFail(r.skill.Name, r.message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,25 +307,31 @@ func handleGitDiscovery(source *install.Source, cfg *config.Config, opts install
|
||||
|
||||
func promptSkillSelection(skills []install.SkillInfo) ([]install.SkillInfo, error) {
|
||||
// Build options list with skill name and path
|
||||
// Show "root" for skills with Path="."
|
||||
options := make([]string, len(skills))
|
||||
for i, skill := range skills {
|
||||
label := skill.Path
|
||||
loc := skill.Path
|
||||
if skill.Path == "." {
|
||||
label = "root"
|
||||
loc = "root"
|
||||
}
|
||||
options[i] = fmt.Sprintf("%s (%s)", skill.Name, label)
|
||||
options[i] = fmt.Sprintf("%s \033[90m%s\033[0m", skill.Name, loc)
|
||||
}
|
||||
|
||||
// Custom survey icons for cleaner look
|
||||
// Space to select, Enter to confirm (survey default behavior)
|
||||
var selectedIndices []int
|
||||
prompt := &survey.MultiSelect{
|
||||
Message: "Select skills to install:",
|
||||
Options: options,
|
||||
PageSize: 15,
|
||||
Help: "Use arrow keys to navigate, space to select, enter to confirm",
|
||||
}
|
||||
|
||||
err := survey.AskOne(prompt, &selectedIndices)
|
||||
err := survey.AskOne(prompt, &selectedIndices, survey.WithIcons(func(icons *survey.IconSet) {
|
||||
icons.UnmarkedOption.Text = " "
|
||||
icons.MarkedOption.Text = "✓"
|
||||
icons.MarkedOption.Format = "green"
|
||||
icons.SelectFocus.Text = "▸"
|
||||
icons.SelectFocus.Format = "yellow"
|
||||
}))
|
||||
if err != nil {
|
||||
return nil, nil // User cancelled (Ctrl+C)
|
||||
}
|
||||
@@ -316,31 +346,37 @@ func promptSkillSelection(skills []install.SkillInfo) ([]install.SkillInfo, erro
|
||||
}
|
||||
|
||||
func handleGitSubdirInstall(source *install.Source, cfg *config.Config, opts install.InstallOptions) error {
|
||||
// Header box
|
||||
ui.HeaderBox("skillshare install", fmt.Sprintf("Source: %s\nSubdirectory: %s", source.Raw, source.Subdir))
|
||||
fmt.Println()
|
||||
// Show logo with version
|
||||
ui.Logo(appversion.Version)
|
||||
|
||||
spinner := ui.StartSpinner("Cloning repository...")
|
||||
// Step 1: Show source
|
||||
ui.StepStart("Source", source.Raw)
|
||||
ui.StepContinue("Subdir", source.Subdir)
|
||||
|
||||
// Step 2: Clone with tree spinner
|
||||
treeSpinner := ui.StartTreeSpinner("Cloning repository...", false)
|
||||
|
||||
// Discover skills in subdir
|
||||
discovery, err := install.DiscoverFromGitSubdir(source)
|
||||
if err != nil {
|
||||
spinner.Fail("Failed to clone")
|
||||
treeSpinner.Fail("Failed to clone")
|
||||
return err
|
||||
}
|
||||
defer install.CleanupDiscovery(discovery)
|
||||
|
||||
treeSpinner.Success("Cloned")
|
||||
|
||||
// If only one skill found, install directly
|
||||
if len(discovery.Skills) == 1 {
|
||||
skill := discovery.Skills[0]
|
||||
spinner.Success(fmt.Sprintf("Found 1 skill: %s", skill.Name))
|
||||
fmt.Println()
|
||||
ui.StepEnd("Found", fmt.Sprintf("1 skill: %s", skill.Name))
|
||||
|
||||
destPath := filepath.Join(cfg.Source, skill.Name)
|
||||
if opts.Name != "" {
|
||||
destPath = filepath.Join(cfg.Source, opts.Name)
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
installSpinner := ui.StartSpinner(fmt.Sprintf("Installing %s...", skill.Name))
|
||||
|
||||
result, err := install.InstallFromDiscovery(discovery, skill, destPath, opts)
|
||||
@@ -369,27 +405,24 @@ func handleGitSubdirInstall(source *install.Source, cfg *config.Config, opts ins
|
||||
|
||||
// Multiple skills found - enter discovery mode
|
||||
if len(discovery.Skills) == 0 {
|
||||
spinner.Fail("No skills found")
|
||||
ui.Warning("No skills found in subdirectory (no SKILL.md files)")
|
||||
ui.StepEnd("Found", "No skills (no SKILL.md files)")
|
||||
return nil
|
||||
}
|
||||
|
||||
spinner.Success(fmt.Sprintf("Found %d skill(s) in subdirectory", len(discovery.Skills)))
|
||||
fmt.Println()
|
||||
ui.StepEnd("Found", fmt.Sprintf("%d skill(s)", len(discovery.Skills)))
|
||||
|
||||
if opts.DryRun {
|
||||
fmt.Println()
|
||||
for _, skill := range discovery.Skills {
|
||||
label := skill.Path
|
||||
if skill.Path == "." {
|
||||
label = "root"
|
||||
}
|
||||
ui.ListItem("info", skill.Name, label)
|
||||
ui.SkillBoxCompact(skill.Name, skill.Path)
|
||||
}
|
||||
fmt.Println()
|
||||
ui.Warning("[dry-run] Would prompt for selection")
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
|
||||
// Prompt for selection
|
||||
selected, err := promptSkillSelection(discovery.Skills)
|
||||
if err != nil {
|
||||
@@ -411,10 +444,13 @@ func handleGitSubdirInstall(source *install.Source, cfg *config.Config, opts ins
|
||||
}
|
||||
results := make([]installResult, 0, len(selected))
|
||||
|
||||
spinner = ui.StartSpinner(fmt.Sprintf("Installing %d skill(s)...", len(selected)))
|
||||
installSpinner := ui.StartSpinnerWithSteps("Installing...", len(selected))
|
||||
|
||||
for i, skill := range selected {
|
||||
spinner.Update(fmt.Sprintf("Installing %s... (%d/%d)", skill.Name, i+1, len(selected)))
|
||||
installSpinner.NextStep(fmt.Sprintf("Installing %s...", skill.Name))
|
||||
if i == 0 {
|
||||
installSpinner.Update(fmt.Sprintf("Installing %s...", skill.Name))
|
||||
}
|
||||
destPath := filepath.Join(cfg.Source, skill.Name)
|
||||
|
||||
_, err := install.InstallFromDiscovery(discovery, skill, destPath, opts)
|
||||
@@ -437,20 +473,20 @@ func handleGitSubdirInstall(source *install.Source, cfg *config.Config, opts ins
|
||||
}
|
||||
|
||||
if failed > 0 && installed == 0 {
|
||||
spinner.Fail(fmt.Sprintf("Failed to install %d skill(s)", failed))
|
||||
installSpinner.Fail(fmt.Sprintf("Failed to install %d skill(s)", failed))
|
||||
} else if failed > 0 {
|
||||
spinner.Success(fmt.Sprintf("Installed %d skill(s), %d failed", installed, failed))
|
||||
installSpinner.Success(fmt.Sprintf("Installed %d, failed %d", installed, failed))
|
||||
} else {
|
||||
spinner.Success(fmt.Sprintf("Installed %d skill(s)", installed))
|
||||
installSpinner.Success(fmt.Sprintf("Installed %d skill(s)", installed))
|
||||
}
|
||||
|
||||
// Show results
|
||||
fmt.Println()
|
||||
for _, r := range results {
|
||||
if r.success {
|
||||
ui.ListItem("success", r.skill.Name, r.message)
|
||||
ui.StepDone(r.skill.Name, "installed")
|
||||
} else {
|
||||
ui.ListItem("error", r.skill.Name, r.message)
|
||||
ui.StepFail(r.skill.Name, r.message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,34 +516,39 @@ func handleDirectInstall(source *install.Source, cfg *config.Config, opts instal
|
||||
// Determine destination path
|
||||
destPath := filepath.Join(cfg.Source, skillName)
|
||||
|
||||
// Header box
|
||||
subtitle := fmt.Sprintf("Source: %s\nName: %s", source.Raw, skillName)
|
||||
if source.HasSubdir() {
|
||||
subtitle += fmt.Sprintf("\nSubdirectory: %s", source.Subdir)
|
||||
}
|
||||
ui.HeaderBox("skillshare install", subtitle)
|
||||
fmt.Println()
|
||||
// Show logo with version
|
||||
ui.Logo(appversion.Version)
|
||||
|
||||
var spinner *ui.Spinner
|
||||
if source.IsGit() {
|
||||
spinner = ui.StartSpinner("Cloning repository...")
|
||||
} else {
|
||||
spinner = ui.StartSpinner("Copying files...")
|
||||
// Step 1: Show source info
|
||||
ui.StepStart("Source", source.Raw)
|
||||
ui.StepContinue("Name", skillName)
|
||||
if source.HasSubdir() {
|
||||
ui.StepContinue("Subdir", source.Subdir)
|
||||
}
|
||||
|
||||
// Step 2: Clone/copy with tree spinner
|
||||
var actionMsg string
|
||||
if source.IsGit() {
|
||||
actionMsg = "Cloning repository..."
|
||||
} else {
|
||||
actionMsg = "Copying files..."
|
||||
}
|
||||
treeSpinner := ui.StartTreeSpinner(actionMsg, true)
|
||||
|
||||
// Execute installation
|
||||
result, err := install.Install(source, destPath, opts)
|
||||
if err != nil {
|
||||
spinner.Fail("Failed to install")
|
||||
treeSpinner.Fail("Failed to install")
|
||||
return err
|
||||
}
|
||||
|
||||
// Display result
|
||||
if opts.DryRun {
|
||||
spinner.Stop()
|
||||
treeSpinner.Success("Ready")
|
||||
fmt.Println()
|
||||
ui.Warning("[dry-run] %s", result.Action)
|
||||
} else {
|
||||
spinner.Success(fmt.Sprintf("Installed: %s", skillName))
|
||||
treeSpinner.Success(fmt.Sprintf("Installed: %s", skillName))
|
||||
}
|
||||
|
||||
// Display warnings
|
||||
|
||||
@@ -11,6 +11,9 @@ import (
|
||||
var version = "dev"
|
||||
|
||||
func main() {
|
||||
// Set version for other packages to use
|
||||
versioncheck.Version = version
|
||||
|
||||
if len(os.Args) < 2 {
|
||||
printUsage()
|
||||
os.Exit(1)
|
||||
|
||||
@@ -18,6 +18,8 @@ import (
|
||||
)
|
||||
|
||||
func cmdStatus(args []string) error {
|
||||
ui.Logo(version)
|
||||
|
||||
cfg, err := config.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -9,17 +9,38 @@ require (
|
||||
atomicgo.dev/keyboard v0.2.9 // indirect
|
||||
atomicgo.dev/schedule v0.1.0 // indirect
|
||||
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
|
||||
github.com/atotto/clipboard v0.1.4 // indirect
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/catppuccin/go v0.3.0 // indirect
|
||||
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 // indirect
|
||||
github.com/charmbracelet/bubbletea v1.3.6 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
|
||||
github.com/charmbracelet/huh v0.8.0 // indirect
|
||||
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.9.3 // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
|
||||
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/containerd/console v1.0.5 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
||||
github.com/gookit/color v1.5.4 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
github.com/lithammer/fuzzysearch v1.1.8 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.2 // indirect
|
||||
github.com/mattn/go-isatty v0.0.8 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||
github.com/muesli/termenv v0.16.0 // indirect
|
||||
github.com/pterm/pterm v0.12.82 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
golang.org/x/sync v0.15.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/term v0.32.0 // indirect
|
||||
golang.org/x/text v0.26.0 // indirect
|
||||
|
||||
@@ -15,12 +15,40 @@ github.com/MarvinJWendt/testza v0.3.0/go.mod h1:eFcL4I0idjtIx8P9C6KkAuLgATNKpX4/
|
||||
github.com/MarvinJWendt/testza v0.4.2/go.mod h1:mSdhXiKH8sg/gQehJ63bINcCKp7RtYewEjXsvsVUPbE=
|
||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
|
||||
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
|
||||
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
|
||||
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY=
|
||||
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
|
||||
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws=
|
||||
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw=
|
||||
github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU=
|
||||
github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
|
||||
github.com/charmbracelet/huh v0.8.0 h1:Xz/Pm2h64cXQZn/Jvele4J3r7DDiqFCNIVteYukxDvY=
|
||||
github.com/charmbracelet/huh v0.8.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
|
||||
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
||||
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
||||
github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0=
|
||||
github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
|
||||
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4=
|
||||
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
|
||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
||||
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
|
||||
github.com/containerd/console v1.0.5 h1:R0ymNeydRqH2DmakFNdmjR2k0t7UPuiOV/N/27/qqsc=
|
||||
github.com/containerd/console v1.0.5/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
|
||||
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
|
||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
|
||||
github.com/gookit/color v1.4.2/go.mod h1:fqRyamkC1W8uxl+lxCQxOT09l/vYfZ+QeiX3rKQHCoQ=
|
||||
github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo=
|
||||
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
|
||||
@@ -36,15 +64,29 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4=
|
||||
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
||||
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
||||
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
|
||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
|
||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
|
||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
||||
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pterm/pterm v0.12.27/go.mod h1:PhQ89w4i95rhgE+xedAoqous6K9X+r6aSOI2eFF7DZI=
|
||||
github.com/pterm/pterm v0.12.29/go.mod h1:WI3qxgvoQFFGKGjGnJR849gU0TsEOvKn5Q8LlY1U7lg=
|
||||
@@ -78,12 +120,15 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
|
||||
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -91,6 +136,7 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9w
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
|
||||
@@ -517,16 +517,15 @@ func isGitRepo(path string) bool {
|
||||
return IsGitRepo(path)
|
||||
}
|
||||
|
||||
// cloneRepo performs a git clone with progress output
|
||||
// cloneRepo performs a git clone (quiet mode for cleaner output)
|
||||
func cloneRepo(url, destPath string, shallow bool) error {
|
||||
args := []string{"clone", "--progress"}
|
||||
args := []string{"clone", "--quiet"}
|
||||
if shallow {
|
||||
args = append(args, "--depth", "1")
|
||||
}
|
||||
args = append(args, url, destPath)
|
||||
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd.Stderr = os.Stderr // Show git progress
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
@@ -708,10 +707,9 @@ func updateTrackedRepo(repoPath string, result *TrackedRepoResult, opts InstallO
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// cloneRepoFull performs a full git clone with progress output
|
||||
// cloneRepoFull performs a full git clone (quiet mode for cleaner output)
|
||||
func cloneRepoFull(url, destPath string) error {
|
||||
cmd := exec.Command("git", "clone", "--progress", url, destPath)
|
||||
cmd.Stderr = os.Stderr // Show git progress
|
||||
cmd := exec.Command("git", "clone", "--quiet", url, destPath)
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
|
||||
@@ -468,3 +468,253 @@ func ListItem(status, name, detail string) {
|
||||
fmt.Printf(" %s %-20s %s\n", statusIcon, name, detail)
|
||||
}
|
||||
}
|
||||
|
||||
// Step-based UI components for install flow
|
||||
|
||||
const (
|
||||
StepArrow = "▸"
|
||||
StepCheck = "✓"
|
||||
StepCross = "✗"
|
||||
StepBullet = "●"
|
||||
StepLine = "│"
|
||||
StepBranch = "├"
|
||||
StepCorner = "└"
|
||||
)
|
||||
|
||||
// StepStart prints the first step (with arrow)
|
||||
func StepStart(label, value string) {
|
||||
if IsTTY() {
|
||||
fmt.Printf("%s %s %s\n", pterm.Yellow(StepArrow), pterm.White(label), value)
|
||||
} else {
|
||||
fmt.Printf("%s %s %s\n", StepArrow, label, value)
|
||||
}
|
||||
}
|
||||
|
||||
// StepContinue prints a middle step (with branch)
|
||||
func StepContinue(label, value string) {
|
||||
if IsTTY() {
|
||||
fmt.Printf("%s\n", pterm.Gray(StepLine))
|
||||
fmt.Printf("%s %s %s\n", pterm.Gray(StepBranch+"─"), pterm.White(label), value)
|
||||
} else {
|
||||
fmt.Printf("%s\n", StepLine)
|
||||
fmt.Printf("%s─ %s %s\n", StepBranch, label, value)
|
||||
}
|
||||
}
|
||||
|
||||
// StepEnd prints the last step (with corner)
|
||||
func StepEnd(label, value string) {
|
||||
if IsTTY() {
|
||||
fmt.Printf("%s\n", pterm.Gray(StepLine))
|
||||
fmt.Printf("%s %s %s\n", pterm.Gray(StepCorner+"─"), pterm.White(label), value)
|
||||
} else {
|
||||
fmt.Printf("%s\n", StepLine)
|
||||
fmt.Printf("%s─ %s %s\n", StepCorner, label, value)
|
||||
}
|
||||
}
|
||||
|
||||
// TreeSpinner is a spinner that fits into tree structure
|
||||
type TreeSpinner struct {
|
||||
spinner *pterm.SpinnerPrinter
|
||||
start time.Time
|
||||
isLast bool
|
||||
}
|
||||
|
||||
// StartTreeSpinner starts a spinner in tree context
|
||||
func StartTreeSpinner(message string, isLast bool) *TreeSpinner {
|
||||
prefix := StepBranch + "─"
|
||||
if isLast {
|
||||
prefix = StepCorner + "─"
|
||||
}
|
||||
|
||||
if !IsTTY() {
|
||||
fmt.Printf("%s\n", StepLine)
|
||||
fmt.Printf("%s %s\n", prefix, message)
|
||||
return &TreeSpinner{start: time.Now(), isLast: isLast}
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", pterm.Gray(StepLine))
|
||||
|
||||
// Custom spinner with tree prefix
|
||||
s, _ := pterm.DefaultSpinner.
|
||||
WithRemoveWhenDone(true).
|
||||
Start(message)
|
||||
|
||||
return &TreeSpinner{spinner: s, start: time.Now(), isLast: isLast}
|
||||
}
|
||||
|
||||
// Success completes the tree spinner with success
|
||||
func (ts *TreeSpinner) Success(message string) {
|
||||
elapsed := time.Since(ts.start)
|
||||
|
||||
prefix := StepBranch + "─"
|
||||
if ts.isLast {
|
||||
prefix = StepCorner + "─"
|
||||
}
|
||||
|
||||
if ts.spinner != nil {
|
||||
ts.spinner.Stop()
|
||||
}
|
||||
|
||||
if IsTTY() {
|
||||
fmt.Printf("%s %s %s\n", pterm.Gray(prefix), pterm.Green(message), pterm.Gray(fmt.Sprintf("(%.1fs)", elapsed.Seconds())))
|
||||
} else {
|
||||
fmt.Printf("%s %s (%.1fs)\n", prefix, message, elapsed.Seconds())
|
||||
}
|
||||
}
|
||||
|
||||
// Fail completes the tree spinner with failure
|
||||
func (ts *TreeSpinner) Fail(message string) {
|
||||
prefix := StepBranch + "─"
|
||||
if ts.isLast {
|
||||
prefix = StepCorner + "─"
|
||||
}
|
||||
|
||||
if ts.spinner != nil {
|
||||
ts.spinner.Stop()
|
||||
}
|
||||
|
||||
if IsTTY() {
|
||||
fmt.Printf("%s %s\n", pterm.Gray(prefix), pterm.Red(message))
|
||||
} else {
|
||||
fmt.Printf("%s %s\n", prefix, message)
|
||||
}
|
||||
}
|
||||
|
||||
// StepItem prints a step with label and value (legacy, use StepStart/Continue/End)
|
||||
func StepItem(label, value string) {
|
||||
if IsTTY() {
|
||||
fmt.Printf("%s %-10s %s\n", pterm.Yellow(StepArrow), pterm.White(label), value)
|
||||
} else {
|
||||
fmt.Printf("%s %-10s %s\n", StepArrow, label, value)
|
||||
}
|
||||
}
|
||||
|
||||
// StepDone prints a completed step
|
||||
func StepDone(label, value string) {
|
||||
if IsTTY() {
|
||||
fmt.Printf("%s %-10s %s\n", pterm.Green(StepCheck), pterm.White(label), value)
|
||||
} else {
|
||||
fmt.Printf("%s %-10s %s\n", StepCheck, label, value)
|
||||
}
|
||||
}
|
||||
|
||||
// StepFail prints a failed step
|
||||
func StepFail(label, value string) {
|
||||
if IsTTY() {
|
||||
fmt.Printf("%s %-10s %s\n", pterm.Red(StepCross), pterm.White(label), value)
|
||||
} else {
|
||||
fmt.Printf("%s %-10s %s\n", StepCross, label, value)
|
||||
}
|
||||
}
|
||||
|
||||
// SkillBox prints a skill in a styled box with name and description
|
||||
func SkillBox(name, description, location string) {
|
||||
if !IsTTY() {
|
||||
fmt.Printf("\n── %s ──\n", name)
|
||||
if description != "" {
|
||||
fmt.Printf(" %s\n", description)
|
||||
}
|
||||
if location != "" {
|
||||
fmt.Printf(" Location: %s\n", location)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Build content lines
|
||||
var lines []string
|
||||
lines = append(lines, "")
|
||||
|
||||
if description != "" {
|
||||
wrapped := wrapText(description, 55)
|
||||
for _, line := range wrapped {
|
||||
lines = append(lines, " "+line)
|
||||
}
|
||||
}
|
||||
|
||||
if location != "" {
|
||||
lines = append(lines, "")
|
||||
lines = append(lines, fmt.Sprintf(" %s %s", pterm.Gray("Location:"), pterm.Gray(location)))
|
||||
}
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
// Calculate max width
|
||||
maxLen := 0
|
||||
for _, line := range lines {
|
||||
w := displayWidth(line)
|
||||
if w > maxLen {
|
||||
maxLen = w
|
||||
}
|
||||
}
|
||||
|
||||
// Pad lines
|
||||
var content strings.Builder
|
||||
for i, line := range lines {
|
||||
padded := line
|
||||
w := displayWidth(line)
|
||||
if w < maxLen {
|
||||
padded = line + strings.Repeat(" ", maxLen-w)
|
||||
}
|
||||
content.WriteString(padded)
|
||||
if i < len(lines)-1 {
|
||||
content.WriteString("\n")
|
||||
}
|
||||
}
|
||||
|
||||
box := pterm.DefaultBox.
|
||||
WithTitle(pterm.Cyan(name)).
|
||||
WithTitleTopLeft()
|
||||
box.Println(content.String())
|
||||
}
|
||||
|
||||
// SkillBoxCompact prints a compact skill box (for multiple skills)
|
||||
func SkillBoxCompact(name, location string) {
|
||||
if IsTTY() {
|
||||
loc := location
|
||||
if loc == "." {
|
||||
loc = "root"
|
||||
}
|
||||
fmt.Printf(" %s %s %s\n", pterm.Cyan(StepBullet), pterm.White(name), pterm.Gray("("+loc+")"))
|
||||
} else {
|
||||
loc := location
|
||||
if loc == "." {
|
||||
loc = "root"
|
||||
}
|
||||
fmt.Printf(" %s %s (%s)\n", StepBullet, name, loc)
|
||||
}
|
||||
}
|
||||
|
||||
// SkillDisplay holds skill info for display
|
||||
type SkillDisplay struct {
|
||||
Name string
|
||||
Description string
|
||||
Path string
|
||||
}
|
||||
|
||||
// wrapText wraps text to specified width
|
||||
func wrapText(text string, width int) []string {
|
||||
if len(text) <= width {
|
||||
return []string{text}
|
||||
}
|
||||
|
||||
var lines []string
|
||||
words := strings.Fields(text)
|
||||
currentLine := ""
|
||||
|
||||
for _, word := range words {
|
||||
if currentLine == "" {
|
||||
currentLine = word
|
||||
} else if len(currentLine)+1+len(word) <= width {
|
||||
currentLine += " " + word
|
||||
} else {
|
||||
lines = append(lines, currentLine)
|
||||
currentLine = word
|
||||
}
|
||||
}
|
||||
|
||||
if currentLine != "" {
|
||||
lines = append(lines, currentLine)
|
||||
}
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Version is set by main.go at startup
|
||||
var Version = "dev"
|
||||
|
||||
const (
|
||||
githubRepo = "runkids/skillshare"
|
||||
checkInterval = 24 * time.Hour
|
||||
|
||||
Reference in New Issue
Block a user