Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cli/install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# install.sh — installer for hypercar-colorscripts (v0.3.2)
# install.sh — installer for hypercar-colorscripts (v0.3.3)
#
# Removed: shell tab completion installation (bash/zsh/fish).
# Everything else preserved from v0.3.1.
# Fixes: pokemon_mix now written as a proper JSON boolean (not a quoted
# string), matching the *bool schema the Go binary expects to unmarshal.
#
# Flags:
# --system binary -> /usr/local/bin (sudo)
Expand Down Expand Up @@ -61,9 +61,9 @@ if command -v pokemon-colorscripts >/dev/null 2>&1; then
ok "pokemon-colorscripts detected at $(command -v pokemon-colorscripts)"
fi

# 2. Build
# 2. Build (always rebuild — Go caches internally, this is cheap)
step "2/8 Binary"
[[ -x "$SCRIPT_DIR/$BINARY" ]] || (cd "$SCRIPT_DIR" && make build) || fail "make build failed"
(cd "$SCRIPT_DIR" && make build) || fail "make build failed"
ok "$SCRIPT_DIR/$BINARY"

# 3. Source data
Expand Down Expand Up @@ -140,6 +140,8 @@ else
fi
ok "Assets in $DATA_DIR"

# Note: pokemon_mix is written as an unquoted JSON boolean (true/false).
# Any other quoting will break unmarshaling in Go and revert to default (true).
mkdir -p "$CONFIG_DIR"
cat > "$CONFIG_FILE" <<EOF
{
Expand Down
22 changes: 12 additions & 10 deletions cli/internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ var (
flagSetMode string // --set-mode flag
flagSetMix string // --set-mix flag

// CHANGE 1: Added vintage flags
flagInstallVintage bool
flagUninstallVintage bool

Expand Down Expand Up @@ -91,7 +90,6 @@ Examples:
pf.StringVar(&flagSetMode, "set-mode", "", "update default_mode in config (auto|ansi) and exit")
pf.StringVar(&flagSetMix, "set-mix", "", "toggle pokemon mixing in shell startup (on|off) and exit")

// CHANGE 2: Registered vintage flags
pf.BoolVar(&flagInstallVintage, "install-vintage", false, "install vintage cars (pre-2000) from the source repo")
pf.BoolVar(&flagUninstallVintage, "uninstall-vintage", false, "remove vintage cars (pre-2000) from the installation")

Expand Down Expand Up @@ -188,7 +186,9 @@ func run(cmd *cobra.Command, args []string) error {
default:
return fmt.Errorf("invalid --set-mix value %q (must be 'on' or 'off')", flagSetMix)
}
cfg.WithPokemon = mix
// Write to the correct field: PokemonMix (which the shell block reads),
// NOT WithPokemon (a deprecated field for the binary's internal mixing).
cfg.PokemonMix = &mix
if err := config.Save(cfg); err != nil {
return fmt.Errorf("saving config: %w", err)
}
Expand All @@ -198,18 +198,16 @@ func run(cmd *cobra.Command, args []string) error {
}
fmt.Printf("pokemon_mix set to: %s\n", state)
if mix {
if _, err := os.Stat("/usr/bin/pokemon-colorscripts"); err != nil {
if _, err := exec.LookPath("pokemon-colorscripts"); err != nil {
fmt.Println("Note: pokemon-colorscripts is not installed, so mixing won't happen even with --set-mix on.")
fmt.Println("Install it from https://gitlab.com/phoneybadger/pokemon-colorscripts")
}
if _, err := exec.LookPath("pokemon-colorscripts"); err != nil {
fmt.Println("Note: pokemon-colorscripts is not installed, so mixing won't happen even with --set-mix on.")
fmt.Println("Install it from https://gitlab.com/phoneybadger/pokemon-colorscripts")
}
}
fmt.Println("Open a new terminal to see the change take effect at startup.")
return nil
}

// CHANGE 3: Dispatch vintage flags
// Vintage flags short-circuit everything else
if flagInstallVintage {
return runInstallVintage()
}
Expand Down Expand Up @@ -350,6 +348,10 @@ func pickMode(cfg config.Config) renderer.Mode {
return renderer.Auto
}

// shouldUsePokemon decides whether the BINARY should show a pokemon on
// bare invocation. This is separate from the shell startup block's own
// 50/50 mixing (which reads PokemonMix from config directly via sed).
// The binary's internal mixing is off by default and rarely used.
func shouldUsePokemon(cfg config.Config) bool {
if flagNoPokemon {
return false
Expand Down Expand Up @@ -436,7 +438,7 @@ func doDoctor(dataDir string, cfg config.Config) error {
fmt.Printf("Config path: %s\n", config.Path())
fmt.Printf("Data dir: %s\n", dataDir)
fmt.Printf("Default mode: %s\n", cfg.DefaultMode)
fmt.Printf("With pokemon: %v\n", cfg.WithPokemon)
fmt.Printf("Pokemon mix: %v (effective; from pokemon_mix field)\n", cfg.EffectiveMix())
fmt.Printf("Terminal: %s\n", terminal.Detect())

if _, err := exec.LookPath("chafa"); err == nil {
Expand Down
Loading