hctl 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. hctl-0.1.0/CODE_OF_CONDUCT.md +33 -0
  2. hctl-0.1.0/CONTRIBUTING.md +71 -0
  3. hctl-0.1.0/LICENSE +22 -0
  4. hctl-0.1.0/MANIFEST.in +10 -0
  5. hctl-0.1.0/PKG-INFO +349 -0
  6. hctl-0.1.0/README.md +318 -0
  7. hctl-0.1.0/SECURITY.md +21 -0
  8. hctl-0.1.0/docs/architecture.md +140 -0
  9. hctl-0.1.0/docs/commands.md +257 -0
  10. hctl-0.1.0/docs/distribution.md +180 -0
  11. hctl-0.1.0/docs/endpoint-coverage.md +482 -0
  12. hctl-0.1.0/install.sh +94 -0
  13. hctl-0.1.0/pyproject.toml +62 -0
  14. hctl-0.1.0/scripts/build_standalone.py +42 -0
  15. hctl-0.1.0/scripts/render_homebrew_formula.py +55 -0
  16. hctl-0.1.0/scripts/update_openapi_manifest.py +381 -0
  17. hctl-0.1.0/scripts/validate_openapi_manifest.py +136 -0
  18. hctl-0.1.0/setup.cfg +4 -0
  19. hctl-0.1.0/src/harness_cli/__init__.py +3 -0
  20. hctl-0.1.0/src/harness_cli/__main__.py +6 -0
  21. hctl-0.1.0/src/harness_cli/cli.py +1857 -0
  22. hctl-0.1.0/src/harness_cli/config.py +290 -0
  23. hctl-0.1.0/src/harness_cli/data/__init__.py +1 -0
  24. hctl-0.1.0/src/harness_cli/data/operations.json +193353 -0
  25. hctl-0.1.0/src/harness_cli/http.py +704 -0
  26. hctl-0.1.0/src/harness_cli/manifest.py +197 -0
  27. hctl-0.1.0/src/harness_cli/render.py +465 -0
  28. hctl-0.1.0/src/hctl.egg-info/PKG-INFO +349 -0
  29. hctl-0.1.0/src/hctl.egg-info/SOURCES.txt +37 -0
  30. hctl-0.1.0/src/hctl.egg-info/dependency_links.txt +1 -0
  31. hctl-0.1.0/src/hctl.egg-info/entry_points.txt +2 -0
  32. hctl-0.1.0/src/hctl.egg-info/requires.txt +7 -0
  33. hctl-0.1.0/src/hctl.egg-info/top_level.txt +1 -0
  34. hctl-0.1.0/tests/__init__.py +1 -0
  35. hctl-0.1.0/tests/test_cli.py +1244 -0
  36. hctl-0.1.0/tests/test_config.py +159 -0
  37. hctl-0.1.0/tests/test_http.py +793 -0
  38. hctl-0.1.0/tests/test_manifest.py +40 -0
  39. hctl-0.1.0/tests/test_render.py +225 -0
@@ -0,0 +1,33 @@
1
+ # Code of Conduct
2
+
3
+ Harness CLI should be a useful, welcoming place for people building and using
4
+ developer tools.
5
+
6
+ ## Standards
7
+
8
+ Please:
9
+
10
+ - Be respectful, patient, and direct.
11
+ - Assume good intent, especially when discussing bugs or unclear behavior.
12
+ - Share context, reproduction steps, and evidence when reporting problems.
13
+ - Keep feedback focused on the work and its impact.
14
+ - Respect privacy. Do not post API keys, private account identifiers, customer
15
+ data, or private endpoint payloads.
16
+
17
+ Please do not:
18
+
19
+ - Harass, threaten, insult, or demean other contributors.
20
+ - Use sexualized, discriminatory, or exclusionary language.
21
+ - Publish another person's private information.
22
+ - Derail technical discussions with repeated off-topic comments.
23
+ - Pressure maintainers or contributors for unpaid work on your timeline.
24
+
25
+ ## Enforcement
26
+
27
+ Maintainers may edit, hide, or remove content that violates this code of
28
+ conduct. They may also warn contributors, temporarily limit participation, or
29
+ block participation when behavior creates risk for other people or the project.
30
+
31
+ If you see a problem, contact the repository owner privately with the relevant
32
+ links, screenshots, or command output. Reports will be handled with care and
33
+ with as much confidentiality as practical.
@@ -0,0 +1,71 @@
1
+ # Contributing
2
+
3
+ Thanks for helping make the Harness CLI better.
4
+
5
+ Please read and follow the [Code of Conduct](CODE_OF_CONDUCT.md). Keep issues
6
+ and pull requests focused on making the CLI clearer, safer, and more useful.
7
+
8
+ ## Local Setup
9
+
10
+ ```bash
11
+ uv venv
12
+ uv pip install -e ".[dev]"
13
+ uv run python -m unittest
14
+ ```
15
+
16
+ The CLI has no runtime dependencies. Keep new dependencies out unless they
17
+ remove meaningful complexity and are worth the installation cost.
18
+
19
+ Install local formatting hooks when you start contributing:
20
+
21
+ ```bash
22
+ uv run --extra dev pre-commit install
23
+ uv run --extra dev pre-commit run --all-files
24
+ ```
25
+
26
+ The hooks run Ruff through `uv` so formatting and autofixable lint issues are
27
+ caught before CI gets to make a dramatic little entrance.
28
+
29
+ ## Endpoint Manifest
30
+
31
+ Endpoint commands are generated from the official Harness API docs:
32
+
33
+ ```bash
34
+ uv run python scripts/update_openapi_manifest.py
35
+ ```
36
+
37
+ Commit generated changes together with the generator or runtime code that needs
38
+ them. If the upstream docs change in a way that removes endpoints, call that out
39
+ in the pull request.
40
+
41
+ ## Releases
42
+
43
+ The public package and command name is `hctl`. See
44
+ [docs/distribution.md](docs/distribution.md) for the supported install
45
+ channels, release checklist, PyPI trusted-publishing setup, Homebrew formula
46
+ handoff, standalone zipapp artifact, and curl installer behavior.
47
+
48
+ ## Pull Requests
49
+
50
+ Use the pull request template and include the command output that proves the
51
+ changed CLI behavior. For request-building changes, `hctl ... --dry-run`
52
+ output is usually the most useful evidence.
53
+
54
+ Before opening a PR:
55
+
56
+ ```bash
57
+ uv run ruff format .
58
+ uv run python -m unittest
59
+ uv run python scripts/validate_openapi_manifest.py
60
+ uv run python -m compileall -q src tests scripts
61
+ uv run ruff check .
62
+ uv run mypy src/harness_cli
63
+ uv build --sdist --wheel
64
+ ```
65
+
66
+ GitHub Actions runs the same checks through `uv sync --locked --all-extras --dev`
67
+ on Python 3.10 through 3.13, including `ruff format --check .`, package build,
68
+ and an installed-wheel smoke test.
69
+
70
+ Please keep changes focused. Small, well-documented slices are much easier to
71
+ review than a giant mystery crate of enthusiasm.
hctl-0.1.0/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ian Matson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
hctl-0.1.0/MANIFEST.in ADDED
@@ -0,0 +1,10 @@
1
+ include CODE_OF_CONDUCT.md
2
+ include CONTRIBUTING.md
3
+ include LICENSE
4
+ include README.md
5
+ include SECURITY.md
6
+ include install.sh
7
+ include pyproject.toml
8
+ recursive-include docs *.md
9
+ recursive-include scripts *.py
10
+ recursive-include tests *.py
hctl-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,349 @@
1
+ Metadata-Version: 2.4
2
+ Name: hctl
3
+ Version: 0.1.0
4
+ Summary: Polished OpenAPI-backed command line interface for Harness APIs.
5
+ Author: Ian Matson
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/imatson9119/harness-cli
8
+ Project-URL: Repository, https://github.com/imatson9119/harness-cli
9
+ Project-URL: Issues, https://github.com/imatson9119/harness-cli/issues
10
+ Keywords: harness,cli,openapi,devops
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Build Tools
20
+ Classifier: Topic :: System :: Systems Administration
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: dev
25
+ Requires-Dist: build>=1.2; extra == "dev"
26
+ Requires-Dist: mypy>=1.10; extra == "dev"
27
+ Requires-Dist: pre-commit>=3.7; extra == "dev"
28
+ Requires-Dist: pytest>=8.0; extra == "dev"
29
+ Requires-Dist: ruff>=0.4; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # hctl
33
+
34
+ `hctl` is a polished, OpenAPI-backed command line interface for the Harness
35
+ Software Delivery Platform APIs.
36
+
37
+ The CLI is generated from the public Harness API reference at
38
+ <https://apidocs.harness.io/>. The current manifest includes every operation
39
+ published in the Redocly OpenAPI shared data bundle that is practical to expose
40
+ through a generic CLI caller.
41
+
42
+ ## Install
43
+
44
+ Install the latest code from Git with `uv`:
45
+
46
+ ```bash
47
+ uv tool install git+https://github.com/imatson9119/harness-cli.git
48
+ hctl --help
49
+ ```
50
+
51
+ After the first PyPI release, the shortest install path is:
52
+
53
+ ```bash
54
+ uv tool install hctl
55
+ ```
56
+
57
+ The curl installer prefers the latest GitHub Release artifact and falls back to
58
+ the Git install path when no release artifact is available:
59
+
60
+ ```bash
61
+ curl -fsSL https://raw.githubusercontent.com/imatson9119/harness-cli/main/install.sh | sh
62
+ ```
63
+
64
+ Other supported channels:
65
+
66
+ ```bash
67
+ pipx install hctl
68
+ brew tap imatson9119/tap && brew install hctl
69
+ curl -fsSLO https://github.com/imatson9119/harness-cli/releases/latest/download/hctl.pyz
70
+ chmod +x hctl.pyz
71
+ ./hctl.pyz --help
72
+ ```
73
+
74
+ See [docs/distribution.md](docs/distribution.md) for upgrade, uninstall,
75
+ release, Homebrew, PyPI, and standalone artifact details.
76
+
77
+ Upgrade and remove common installs:
78
+
79
+ ```bash
80
+ uv tool upgrade hctl
81
+ uv tool uninstall hctl
82
+ brew upgrade hctl
83
+ brew uninstall hctl
84
+ rm ~/.local/bin/hctl
85
+ ```
86
+
87
+ ## Onboarding
88
+
89
+ Run the interactive onboarding flow:
90
+
91
+ ```bash
92
+ hctl init
93
+ ```
94
+
95
+ The flow stores configuration in `~/.config/hctl/config.json` by default and
96
+ sets file permissions to `0600`. Config is profile-based, so you can keep
97
+ multiple Harness accounts or projects handy:
98
+
99
+ ```bash
100
+ hctl init --profile prod --output table
101
+ hctl init --profile sandbox
102
+ hctl profile use prod
103
+ hctl profile list
104
+ ```
105
+
106
+ Onboarding asks for host, API key, account, org, project, and default output
107
+ mode. Host values must be full `http://` or `https://` URLs. Use
108
+ `--non-interactive` with flags when scripting setup.
109
+
110
+ Use global options when you want one command to use a different profile or
111
+ config file without changing your active setup:
112
+
113
+ ```bash
114
+ hctl --profile prod doctor
115
+ hctl --config ./harness.config.json auth status
116
+ ```
117
+
118
+ You can also use environment variables:
119
+
120
+ ```bash
121
+ export HARNESS_HOST=https://app.harness.io
122
+ export HARNESS_API_KEY=your-token
123
+ export HARNESS_PROFILE=prod
124
+ export HARNESS_ACCOUNT=your-account-id
125
+ export HARNESS_ORG=optional-org-id
126
+ export HARNESS_PROJECT=optional-project-id
127
+ ```
128
+
129
+ Harness authenticates API calls with the `x-api-key` header. When an endpoint
130
+ requires the Harness account header, `--account` or the active profile account
131
+ is sent as `Harness-Account`. Profile account, org, and project values are also
132
+ used for common generated endpoint parameter spellings such as
133
+ `accountIdentifier`, `accountId`, `account_id`, `orgIdentifier`,
134
+ `organizationIdentifier`, `projectIdentifier`, and snake-case registry
135
+ identifiers.
136
+
137
+ ## Endpoint Commands
138
+
139
+ List generated operations:
140
+
141
+ ```bash
142
+ hctl api list --search pipeline
143
+ hctl api list --search role --wide
144
+ hctl api groups --search pipeline --limit 20
145
+ hctl api list --tag "Account Roles"
146
+ hctl api list --group account-roles --has-body
147
+ hctl api list --method post --path /v1/roles
148
+ ```
149
+
150
+ Describe an operation:
151
+
152
+ ```bash
153
+ hctl api describe list-roles-acc
154
+ ```
155
+
156
+ Descriptions include parameter defaults, enum hints, docs links, pagination
157
+ support, and pasteable examples.
158
+
159
+ Print a request-body template for create/update operations:
160
+
161
+ ```bash
162
+ hctl api body create-role-acc > role.json
163
+ hctl api body create-account-scoped-connector --content-type application/yaml > connector.yaml
164
+ hctl api body create-role-acc --output-file role.json
165
+ hctl api body create-role-acc --json
166
+ ```
167
+
168
+ JSON templates are pretty-printed as JSON. YAML and other text templates are
169
+ printed as editable raw text; add `--json` when you want metadata such as the
170
+ selected content type wrapped around the body.
171
+
172
+ Call an operation through the stable API dispatcher:
173
+
174
+ ```bash
175
+ hctl api call --help
176
+ hctl api call list-roles-acc --help
177
+ hctl api call list-roles-acc --query limit=10 --help
178
+ hctl api call list-roles-acc --query limit=10
179
+ ```
180
+
181
+ Call the same operation through its generated group shortcut:
182
+
183
+ ```bash
184
+ hctl account-roles list-roles-acc --limit 10
185
+ ```
186
+
187
+ Use `--host https://custom.example.com` for one-off calls against another
188
+ Harness base URL. Like saved hosts, per-call host overrides must be full
189
+ `http://` or `https://` URLs without query strings or fragments.
190
+
191
+ Render JSON list responses as a table when you want a compact human view:
192
+
193
+ ```bash
194
+ hctl account-roles list-roles-acc --limit 10 --output table
195
+ hctl account-roles list-roles-acc --limit 10 --output table --columns identifier,name,createdAt
196
+ ```
197
+
198
+ Fetch paginated list endpoints until they are exhausted:
199
+
200
+ ```bash
201
+ hctl account-roles list-roles-acc --all --all-page-size 100 --output table
202
+ ```
203
+
204
+ `--all` recognizes the common pagination shapes in the generated Harness
205
+ manifest, including page, offset, and cursor-style query parameters.
206
+
207
+ Preview the request without sending it:
208
+
209
+ ```bash
210
+ hctl account-roles list-roles-acc --limit 10 --dry-run
211
+ hctl account-roles list-roles-acc --limit 10 --curl
212
+ ```
213
+
214
+ Preview output redacts `x-api-key`, `Authorization`, and common token/secret
215
+ style headers so requests are easier to share safely.
216
+
217
+ Send JSON request bodies from a file:
218
+
219
+ ```bash
220
+ hctl project-services create-service --org my-org --project my-project --body @service.json
221
+ hctl project-services create-service --org my-org --project my-project --body-json @service.json
222
+ hctl api call create-role-acc --body-template --dry-run
223
+ ```
224
+
225
+ Use `--body-json` for inline JSON, `@file`, or `-` stdin when you want the CLI
226
+ to validate the payload before sending it. Use `--body-template` to send the
227
+ generated JSON or YAML request-body sample for an operation; pair it with
228
+ `--dry-run` first when exploring a new endpoint.
229
+
230
+ Upload multipart files for file-oriented endpoints:
231
+
232
+ ```bash
233
+ hctl artifact-signing upload-signature \
234
+ --org my-org \
235
+ --project my-project \
236
+ --form note=release \
237
+ --file signature=@signature.json
238
+ ```
239
+
240
+ Save binary responses:
241
+
242
+ ```bash
243
+ hctl file-store download-file --identifier readme --output-file readme.md
244
+ ```
245
+
246
+ ## Shell Completion
247
+
248
+ Print completion scripts for supported shells:
249
+
250
+ ```bash
251
+ hctl completion bash
252
+ hctl completion zsh
253
+ hctl completion fish
254
+ ```
255
+
256
+ Install completions:
257
+
258
+ ```bash
259
+ mkdir -p ~/.local/share/bash-completion/completions
260
+ hctl completion bash > ~/.local/share/bash-completion/completions/hctl
261
+ mkdir -p ~/.zfunc
262
+ hctl completion zsh > ~/.zfunc/_hctl
263
+ mkdir -p ~/.config/fish/completions
264
+ hctl completion fish > ~/.config/fish/completions/hctl.fish
265
+ ```
266
+
267
+ ## Terminal Experience
268
+
269
+ Interactive terminals get colorized tables, highlighted JSON, Unicode table
270
+ frames, and a live status indicator while API calls are in flight. Scripts
271
+ still get clean output: command data goes to stdout, while status, saved-file
272
+ messages, and clean transport errors go to stderr. HTTP 4xx/5xx responses
273
+ return exit code `1` and still render the response body so scripts can inspect
274
+ it.
275
+
276
+ Controls:
277
+
278
+ ```bash
279
+ NO_COLOR=1 hctl api list
280
+ HARNESS_COLOR=always hctl api list
281
+ HARNESS_ANIMATION=never hctl account-roles list-roles-acc --limit 10
282
+ HARNESS_STATUS=never hctl account-roles list-roles-acc --limit 10
283
+ HARNESS_TABLE_STYLE=unicode hctl account-roles list-roles-acc --output table
284
+ HARNESS_TABLE_STYLE=plain hctl account-roles list-roles-acc --output table
285
+ HARNESS_ASCII=1 hctl account-roles list-roles-acc --limit 10
286
+ ```
287
+
288
+ Use `HARNESS_ANIMATION=never` to keep the final status line without live
289
+ motion. Use `HARNESS_STATUS=never` when you want no call status on stderr.
290
+
291
+ ## Useful Commands
292
+
293
+ ```bash
294
+ hctl doctor
295
+ hctl --profile prod doctor
296
+ hctl doctor --fix-permissions
297
+ hctl doctor --network
298
+ hctl auth status
299
+ hctl profile list
300
+ hctl profile use prod
301
+ hctl config list
302
+ hctl config set account acc_123
303
+ hctl config set default_output table
304
+ hctl api info
305
+ hctl api groups
306
+ hctl api body create-role-acc
307
+ ```
308
+
309
+ ## Development
310
+
311
+ Refresh the generated endpoint manifest from Harness API docs:
312
+
313
+ ```bash
314
+ uv run python scripts/update_openapi_manifest.py
315
+ ```
316
+
317
+ Run the standard library test suite:
318
+
319
+ ```bash
320
+ uv run python -m unittest
321
+ ```
322
+
323
+ Install development tooling and run checks:
324
+
325
+ ```bash
326
+ uv venv
327
+ uv pip install -e ".[dev]"
328
+ uv run ruff format .
329
+ uv run ruff check .
330
+ uv run mypy src/harness_cli
331
+ uv run python scripts/validate_openapi_manifest.py
332
+ uv run python -m compileall -q src tests scripts
333
+ uv build --sdist --wheel
334
+ uv run python scripts/build_standalone.py
335
+ ```
336
+
337
+ Install commit-time formatting hooks:
338
+
339
+ ```bash
340
+ uv run --extra dev pre-commit install
341
+ uv run --extra dev pre-commit run --all-files
342
+ ```
343
+
344
+ The hooks use `uv run --frozen --extra dev ruff format` and
345
+ `uv run --frozen --extra dev ruff check --fix` so everyday commits get the same
346
+ formatter and autofix behavior as CI.
347
+
348
+ See [CONTRIBUTING.md](CONTRIBUTING.md) and
349
+ [docs/architecture.md](docs/architecture.md) for the project shape.