|
| 1 | +# CLI Command Contracts |
| 2 | + |
| 3 | +## Global Options |
| 4 | + |
| 5 | +All commands accept: |
| 6 | + |
| 7 | +- `--branch TEXT` — Target Infrahub branch (default: from config) |
| 8 | +- `--config-file PATH` — Configuration file path (default: infrahubctl.toml) |
| 9 | +- `--output [table|json|csv|yaml]` — Output format (default: table if TTY, json if piped) |
| 10 | + |
| 11 | +## `infrahubctl get <kind> [identifier]` |
| 12 | + |
| 13 | +**List mode** (no identifier): |
| 14 | + |
| 15 | +- Input: kind (positional), --filter (repeatable), --limit INT, --offset INT |
| 16 | +- Output: Table with columns for each attribute + relationship (display names) |
| 17 | +- Exit 0: results found | Exit 80: no results (empty list) | Exit 1: invalid kind |
| 18 | + |
| 19 | +**Detail mode** (with identifier): |
| 20 | + |
| 21 | +- Input: kind (positional), identifier (positional — UUID or display name) |
| 22 | +- Output: Key-value display of all attributes, relationships, metadata |
| 23 | +- Exit 0: found | Exit 1: not found |
| 24 | + |
| 25 | +**Filters**: `--filter name__value="spine01"` (repeatable) |
| 26 | + |
| 27 | +## `infrahubctl create <kind>` |
| 28 | + |
| 29 | +- Input: kind (positional), --set key=value (repeatable), --file PATH |
| 30 | +- --set and --file are mutually exclusive |
| 31 | +- Output: Confirmation with created object ID and display label |
| 32 | +- Exit 0: created | Exit 1: validation error | Exit 1: server error |
| 33 | + |
| 34 | +**File input**: JSON or YAML in Infrahub Object format |
| 35 | +(`apiVersion: infrahub.app/v1`) |
| 36 | + |
| 37 | +## `infrahubctl update <kind> <identifier>` |
| 38 | + |
| 39 | +- Input: kind (positional), identifier (positional), --set key=value |
| 40 | + (repeatable), --file PATH |
| 41 | +- --set and --file are mutually exclusive |
| 42 | +- Output: Confirmation with old → new values for changed fields |
| 43 | +- Exit 0: updated | Exit 1: not found | Exit 1: validation error |
| 44 | + |
| 45 | +## `infrahubctl delete <kind> <identifier>` |
| 46 | + |
| 47 | +- Input: kind (positional), identifier (positional), --yes (skip confirmation) |
| 48 | +- Output: Confirmation prompt (unless --yes), then success message |
| 49 | +- Exit 0: deleted | Exit 1: not found | Exit 1: dependency conflict |
| 50 | + |
| 51 | +## `infrahubctl schema list` |
| 52 | + |
| 53 | +- Input: --filter TEXT (substring match on kind name) |
| 54 | +- Output: Table with columns: Namespace, Name, Kind, Description |
| 55 | +- Exit 0: always (empty table if no matches) |
| 56 | + |
| 57 | +## `infrahubctl schema show <kind>` |
| 58 | + |
| 59 | +- Input: kind (positional) |
| 60 | +- Output: Formatted display of: |
| 61 | + - Kind metadata (namespace, label, description, display_labels, HFID) |
| 62 | + - Attributes table (name, type, required, default, description) |
| 63 | + - Relationships table (name, peer kind, cardinality, optional) |
| 64 | +- Exit 0: found | Exit 1: invalid kind |
0 commit comments