Files
HarborForge.Cli/README.md

78 lines
2.2 KiB
Markdown

# HarborForge.Cli
`HarborForge.Cli` is the Go-based `hf` binary for HarborForge.
## Build
```bash
go build -o ./bin/hf ./cmd/hf
```
To set the version at build time:
```bash
go build -ldflags "-X git.hangman-lab.top/zhi/HarborForge.Cli/internal/commands.Version=1.0.0" -o ./bin/hf ./cmd/hf
```
## Run
```bash
# Show help
./bin/hf --help
# Show only permitted commands
./bin/hf --help-brief
# Show version
./bin/hf version
# Check API health
./bin/hf health
# Configure API URL
./bin/hf config --url http://your-harborforge:8000
# View current config
./bin/hf config
# JSON output
./bin/hf version --json
```
## Package Layout
```text
cmd/hf/ CLI entrypoint
internal/
client/ HTTP client wrapper for HarborForge API
commands/ Command implementations (version, health, config, auth helpers)
config/ Config file resolution and management (.hf-config.json)
help/ Help and help-brief renderer
mode/ Runtime mode detection (padded-cell vs manual)
output/ Output formatting (human-readable, JSON, tables)
passmgr/ pass_mgr integration for secret resolution
```
## Runtime Modes
- **Padded-cell mode**: When `pass_mgr` is available, auth tokens are resolved automatically. Manual `--token` flags are rejected.
- **Manual mode**: When `pass_mgr` is not available, `--token` must be provided explicitly to authenticated commands.
## Current Status
Implemented:
- Go module and binary entrypoint
- Config file resolution relative to binary directory
- Runtime mode detection (`pass_mgr` present/absent)
- Top-level and group/leaf help rendering system (`--help` / `--help-brief` / `not permitted` stubs)
- Permission-aware command visibility via `/auth/me/permissions` when a token is available
- HTTP client wrapper
- Output formatting (human-readable + `--json`)
- `hf version`, `hf health`, `hf config`
- Auth token resolution (padded-cell + manual)
- Backend-aligned role/permission commands, including role-name lookup and permission-name↔id translation against current API routes
Planned:
- User, role, project, task, milestone, meeting, support, propose, monitor commands
- Rich per-command help/usage text beyond the current stub renderer