complete fgj → fj rename: env vars, config migration, docs
Some checks are pending
CI / lint (push) Waiting to run
CI / build (push) Waiting to run
CI / test (push) Waiting to run
CI / functional (push) Blocked by required conditions

- Rename env vars: FGJ_HOST → FJ_HOST, FGJ_TOKEN → FJ_TOKEN,
  FGJ_FORCE_TTY → FJ_FORCE_TTY, FGJ_PAGER → FJ_PAGER,
  FGJ_BINARY_PATH → FJ_BINARY_PATH (all with legacy fallback)
- Auto-migrate ~/.config/fgj/ → ~/.config/fj/ on first run
- Update man page title, README, CHANGELOG
- Update test fixture labels from [FGJ E2E Test] to [FJ E2E Test]
This commit is contained in:
sid 2026-04-26 08:23:48 -06:00
parent cf7c0e0878
commit c3e8ad67ed
9 changed files with 94 additions and 33 deletions

View file

@ -131,7 +131,7 @@ func (c *Config) SaveToPath(path string) error {
// Priority order:
// 1. Explicitly provided hostname parameter
// 2. CLI flag (--hostname)
// 3. Environment variable (FGJ_HOST)
// 3. Environment variable (FJ_HOST, with FGJ_HOST fallback)
// 4. Auto-detected hostname from git remote
// 5. match_dirs lookup (longest prefix match)
// 6. Default to codeberg.org
@ -141,7 +141,7 @@ func (c *Config) GetHost(hostname string, detectedHost string, cwd string) (Host
}
if hostname == "" {
hostname = os.Getenv("FGJ_HOST")
hostname = EnvWithFallback("FJ_HOST", "FGJ_HOST")
}
if hostname == "" {
@ -228,6 +228,15 @@ func (c *Config) ResolveHostByPath(cwd string) string {
}
// expandHome replaces a leading ~ with the user's home directory.
// EnvWithFallback returns the value of the primary env var, falling back to
// the legacy name if the primary is unset. This eases the FGJ_ → FJ_ rename.
func EnvWithFallback(primary, legacy string) string {
if v := os.Getenv(primary); v != "" {
return v
}
return os.Getenv(legacy)
}
func expandHome(path string) string {
if path == "~" || strings.HasPrefix(path, "~/") {
home, err := os.UserHomeDir()

View file

@ -37,10 +37,10 @@ type IOStreams struct {
}
// New creates an IOStreams wired to the real os.Stdin, os.Stdout, and os.Stderr,
// with TTY status auto-detected. Setting FGJ_FORCE_TTY=1 forces all streams to
// be treated as TTYs.
// with TTY status auto-detected. Setting FJ_FORCE_TTY=1 (or legacy FGJ_FORCE_TTY=1)
// forces all streams to be treated as TTYs.
func New() *IOStreams {
forceTTY := os.Getenv("FGJ_FORCE_TTY") != ""
forceTTY := os.Getenv("FJ_FORCE_TTY") != "" || os.Getenv("FGJ_FORCE_TTY") != ""
stdinTTY := forceTTY || (isTerminal(os.Stdin.Fd()))
stdoutTTY := forceTTY || (isTerminal(os.Stdout.Fd()))
@ -118,14 +118,17 @@ func (s *IOStreams) ColorScheme() *ColorScheme {
}
// StartPager starts an external pager process and redirects Out to its stdin.
// It checks FGJ_PAGER, then PAGER, then defaults to "less". If LESS is not
// already set, it is set to "FRX" for a good default experience.
// It checks FJ_PAGER (or legacy FGJ_PAGER), then PAGER, then defaults to "less".
// If LESS is not already set, it is set to "FRX" for a good default experience.
func (s *IOStreams) StartPager() error {
if !s.isStdoutTTY {
return nil
}
pagerCmd := os.Getenv("FGJ_PAGER")
pagerCmd := os.Getenv("FJ_PAGER")
if pagerCmd == "" {
pagerCmd = os.Getenv("FGJ_PAGER")
}
if pagerCmd == "" {
pagerCmd = os.Getenv("PAGER")
}