Skip to content

cli: print shell-specific env-var syntax for phantom start #21

@MasonStation

Description

@MasonStation

Background

After `phantom start` or `phantom start --daemon`, we print the env-var lines the user should paste into their shell:

```
export OPENAI_BASE_URL=http://127.0.0.1:12345/openai
export PHANTOM_PROXY_PORT=12345
export PHANTOM_PROXY_TOKEN=ptx_...
```

These are bash syntax. On Windows PowerShell (`$env:OPENAI_BASE_URL = "..."`) or cmd (`set OPENAI_BASE_URL=...`) they fail with `export: command not found`. Biggest first-run Windows UX issue.

Locations

  • `crates/phantom-cli/src/commands/start.rs:109-114` (daemon path)
  • `crates/phantom-cli/src/commands/start.rs:220-225` (foreground path)

Proposed fix

Detect the user's shell once, print one variant, add a short hint line. First-match-wins rules:

  1. `$SHELL` contains `bash`/`zsh`/`fish`/`sh` → bash-style `export X=Y` (catches Git Bash / WSL / macOS / Linux)
  2. `$PSModulePath` set → PowerShell `$env:X = "Y"`
  3. `cfg(windows)` → cmd `set X=Y`
  4. Fallback → bash-style

After the lines, print one comment with the alternatives so users can self-correct if detection was wrong.

Scope

~50 LOC, no new dependencies. Tiny `ShellSyntax` enum + `detect()` + `format_export()` helpers, called from both start paths.

Part of v0.5.1. Tracker: #1

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwindowsWindows platform support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions