Add custom path support for cli/tui in terminal config
This commit is contained in:
@@ -9,13 +9,13 @@ There are two global commands after install:
|
||||
|
||||
## Global config directory
|
||||
|
||||
Wallet state lives under **`~/.config/xo-cli/`** (XDG-style), so you can run commands from any directory:
|
||||
Wallet state lives under **`${XO_CONFIG_DIR:-~/.config/xo-cli}`**, so you can run commands from any directory. Set `XO_CONFIG_DIR` to use a different wallet-state root.
|
||||
|
||||
| Path | Purpose |
|
||||
| ----------------------------- | ----------------------------------------------------------------------- |
|
||||
| `~/.config/xo-cli/mnemonics/` | Mnemonic files (`mnemonic-*`) |
|
||||
| `~/.config/xo-cli/data/` | Engine DB (`xo-wallet.db`) and invitation storage (`xo-invitations.db`) |
|
||||
| `~/.config/xo-cli/.wallet` | JSON settings (`default-mnemonic`, `currency`) |
|
||||
| Path | Purpose |
|
||||
| -------------------------- | ----------------------------------------------------------------------- |
|
||||
| `$XO_CONFIG_DIR/mnemonics/` | Mnemonic files (`mnemonic-*`) |
|
||||
| `$XO_CONFIG_DIR/data/` | Engine DB (`xo-wallet.db`) and invitation storage (`xo-invitations.db`) |
|
||||
| `$XO_CONFIG_DIR/.wallet` | JSON settings (`default-mnemonic`, `currency`) |
|
||||
|
||||
**Local to your shell’s current directory:** template JSON paths, invitation JSON you create/import, and any path you pass explicitly (e.g. `-m /abs/path/to/file`).
|
||||
|
||||
@@ -39,21 +39,24 @@ npx tsx src/cli/index.ts <command> [options]
|
||||
npx tsx src/index.ts # TUI
|
||||
```
|
||||
|
||||
### Environment variables (TUI / `xo-tui`)
|
||||
### Environment variables
|
||||
|
||||
| Variable | Default |
|
||||
| ------------------------- | ----------------------------------------- |
|
||||
| `XO_CONFIG_DIR` | `~/.config/xo-cli` |
|
||||
| `SYNC_SERVER_URL` | `http://localhost:3000` |
|
||||
| `DB_PATH` | `~/.config/xo-cli/data` |
|
||||
| `DB_PATH` | `$XO_CONFIG_DIR/data` |
|
||||
| `DB_FILENAME` | `xo-wallet.db` |
|
||||
| `INVITATION_STORAGE_PATH` | `~/.config/xo-cli/data/xo-invitations.db` |
|
||||
| `INVITATION_STORAGE_PATH` | `$XO_CONFIG_DIR/data/xo-invitations.db` |
|
||||
|
||||
Use an absolute path for a custom root. Setting `XO_CONFIG_DIR` does not copy state from the default directory.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Wallet Setup
|
||||
|
||||
```bash
|
||||
# Generate a new mnemonic (saved under ~/.config/xo-cli/mnemonics/)
|
||||
# Generate a new mnemonic (saved under $XO_CONFIG_DIR/mnemonics/)
|
||||
xo-cli mnemonic create
|
||||
|
||||
# Import an existing mnemonic seed phrase
|
||||
@@ -68,7 +71,7 @@ xo-cli mnemonic list
|
||||
### Wallet Persistence
|
||||
|
||||
The first time you pass `-m <name>`, that reference is saved as
|
||||
`default-mnemonic` in `~/.config/xo-cli/.wallet`. Later runs can omit `-m`.
|
||||
`default-mnemonic` in `$XO_CONFIG_DIR/.wallet`. Later runs can omit `-m`.
|
||||
|
||||
`currency` controls the fiat unit used when showing BCH/sats conversions in the TUI.
|
||||
|
||||
@@ -76,7 +79,7 @@ Mnemonic resolution order:
|
||||
|
||||
1. Absolute path, if the file exists
|
||||
2. Path relative to the current working directory
|
||||
3. `~/.config/xo-cli/mnemonics/<basename>`
|
||||
3. `$XO_CONFIG_DIR/mnemonics/<basename>`
|
||||
|
||||
```bash
|
||||
xo-cli resource list -m mnemonic-nuclear
|
||||
@@ -93,7 +96,7 @@ xo-cli resource list
|
||||
| `-v`, `--verbose` | Verbose output |
|
||||
| `-h`, `--help` | Help |
|
||||
|
||||
Advanced: you can pass `--database-path`, `--database-filename`, and `--invitation-storage-path` to override the defaults under `~/.config/xo-cli/data/` (see `src/cli/index.ts`).
|
||||
Advanced: you can pass `--database-path`, `--database-filename`, and `--invitation-storage-path` to override the defaults under `$XO_CONFIG_DIR/data/` (see `src/cli/index.ts`).
|
||||
|
||||
## Commands
|
||||
|
||||
@@ -201,9 +204,11 @@ eval "$(xo-cli completions zsh)"
|
||||
xo-cli completions fish | source
|
||||
```
|
||||
|
||||
`xo-cli completions <shell> --install` adds a default `XO_CONFIG_DIR` assignment to the shell startup file if one is not already present. Mnemonic aliases are completed directly from `$XO_CONFIG_DIR/mnemonics/`; database-backed suggestions still use `xo-complete`.
|
||||
|
||||
## File Conventions
|
||||
|
||||
| Location | Purpose |
|
||||
| ------------------- | ------------------------------------------ |
|
||||
| `~/.config/xo-cli/` | Global wallet state |
|
||||
| `./` (cwd) | Templates, invitation JSON, explicit paths |
|
||||
| Location | Purpose |
|
||||
| ---------------- | ------------------------------------------ |
|
||||
| `$XO_CONFIG_DIR` | Global wallet state |
|
||||
| `./` (cwd) | Templates, invitation JSON, explicit paths |
|
||||
|
||||
Reference in New Issue
Block a user