|
| 1 | +# CLI Reference |
| 2 | + |
| 3 | +```bash |
| 4 | +pyarchrules --help |
| 5 | +``` |
| 6 | + |
| 7 | +## Commands |
| 8 | + |
| 9 | +| Command | Description | |
| 10 | +|---------|-------------| |
| 11 | +| `init-project` | Initialise `[tool.pyarchrules]` in `pyproject.toml` | |
| 12 | +| `add-service` | Register a new service | |
| 13 | +| `remove-service` | Remove a service | |
| 14 | +| `list-services` | Show all configured services | |
| 15 | +| `check` | Validate architecture against all rules | |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## `init-project` |
| 20 | + |
| 21 | +```bash |
| 22 | +pyarchrules init-project [PROJECT_ROOT] [--force] |
| 23 | +``` |
| 24 | + |
| 25 | +Writes a default `[tool.pyarchrules]` section to `pyproject.toml`. |
| 26 | + |
| 27 | +| Argument / Option | Default | Description | |
| 28 | +|-------------------|---------|-------------| |
| 29 | +| `PROJECT_ROOT` | `.` | Path to the project root. | |
| 30 | +| `--force`, `-f` | false | Re-initialise without confirmation. | |
| 31 | + |
| 32 | +**Output:** |
| 33 | + |
| 34 | +``` |
| 35 | +✨ Successfully initialized! |
| 36 | +📝 /home/user/myapp/pyproject.toml |
| 37 | +
|
| 38 | +Configuration: |
| 39 | + • root = '.' |
| 40 | + • strict = true |
| 41 | + • validate_paths = true |
| 42 | + • fail_on_warning = false |
| 43 | +``` |
| 44 | + |
| 45 | +Exit codes: `0` success · `1` `pyproject.toml` not found |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## `add-service` |
| 50 | + |
| 51 | +```bash |
| 52 | +pyarchrules add-service [NAME] [PATH] |
| 53 | +``` |
| 54 | + |
| 55 | +Adds or updates a service. Prompts interactively if arguments are omitted. |
| 56 | + |
| 57 | +```bash |
| 58 | +pyarchrules add-service backend src/backend |
| 59 | +pyarchrules add-service # interactive prompts |
| 60 | +``` |
| 61 | + |
| 62 | +**Output:** |
| 63 | + |
| 64 | +``` |
| 65 | +➕ Added service 'backend' |
| 66 | + Path: src/backend |
| 67 | +``` |
| 68 | + |
| 69 | +Exit codes: `0` success · `1` invalid name or config not found |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## `remove-service` |
| 74 | + |
| 75 | +```bash |
| 76 | +pyarchrules remove-service [NAME] [--force] |
| 77 | +``` |
| 78 | + |
| 79 | +Removes a service. Prompts for confirmation unless `--force`. |
| 80 | + |
| 81 | +```bash |
| 82 | +pyarchrules remove-service backend --force |
| 83 | +pyarchrules remove-service # interactive list |
| 84 | +``` |
| 85 | + |
| 86 | +Exit codes: `0` success or cancelled · `1` service not found |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## `list-services` |
| 91 | + |
| 92 | +```bash |
| 93 | +pyarchrules list-services |
| 94 | +``` |
| 95 | + |
| 96 | +**Output:** |
| 97 | + |
| 98 | +``` |
| 99 | +📦 Configured services (3): |
| 100 | +
|
| 101 | + • backend |
| 102 | + src/backend |
| 103 | + • auth |
| 104 | + services/auth |
| 105 | + • shared |
| 106 | + services/shared |
| 107 | +``` |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## `check` |
| 112 | + |
| 113 | +```bash |
| 114 | +pyarchrules check [PROJECT_ROOT] [--strict/--no-strict] [--verbose/--quiet] |
| 115 | +``` |
| 116 | + |
| 117 | +Validates architecture against all rules in `pyproject.toml`. |
| 118 | + |
| 119 | +| Option | Default | Description | |
| 120 | +|--------|---------|-------------| |
| 121 | +| `--strict` / `--no-strict` | from config | Override strict mode. | |
| 122 | +| `--verbose` / `--quiet` | `--verbose` | Show per-service rule detail. | |
| 123 | + |
| 124 | +**Passing:** |
| 125 | + |
| 126 | +``` |
| 127 | +🔍 Checking 2 service(s)... |
| 128 | +
|
| 129 | +📦 backend |
| 130 | + Path: src/backend |
| 131 | + Rules: tree_structure, internal_dependencies |
| 132 | +
|
| 133 | +✨ All checks passed! |
| 134 | + Checked 2 rule(s) across 2 service(s) |
| 135 | +``` |
| 136 | + |
| 137 | +**Failing:** |
| 138 | + |
| 139 | +``` |
| 140 | +❌ Validation failed! |
| 141 | +
|
| 142 | +Found 1 error(s) and 0 warning(s): |
| 143 | +
|
| 144 | +❌ [backend] tree_structure |
| 145 | + Missing required paths: ['domain'] |
| 146 | +``` |
| 147 | + |
| 148 | +**Exit codes:** |
| 149 | + |
| 150 | +| Code | Condition | |
| 151 | +|------|-----------| |
| 152 | +| `0` | All checks passed | |
| 153 | +| `0` | Violations present but `strict = false` | |
| 154 | +| `1` | Errors present and `strict = true` | |
| 155 | +| `1` | Warnings present and `fail_on_warning = true` | |
| 156 | +| `1` | Config could not be loaded | |
0 commit comments