ontrack-cli 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.
- ontrack_cli-0.1.0/.github/workflows/ci.yml +64 -0
- ontrack_cli-0.1.0/.github/workflows/publish.yml +61 -0
- ontrack_cli-0.1.0/.github/workflows/release.yml +59 -0
- ontrack_cli-0.1.0/.gitignore +6 -0
- ontrack_cli-0.1.0/LICENSE +21 -0
- ontrack_cli-0.1.0/PKG-INFO +183 -0
- ontrack_cli-0.1.0/README.md +145 -0
- ontrack_cli-0.1.0/config.example.yaml +10 -0
- ontrack_cli-0.1.0/ontrack_cli/__init__.py +3 -0
- ontrack_cli-0.1.0/ontrack_cli/auth.py +200 -0
- ontrack_cli-0.1.0/ontrack_cli/cli.py +228 -0
- ontrack_cli-0.1.0/ontrack_cli/client.py +226 -0
- ontrack_cli-0.1.0/ontrack_cli/config.py +254 -0
- ontrack_cli-0.1.0/ontrack_cli/constants.py +69 -0
- ontrack_cli-0.1.0/ontrack_cli/exceptions.py +21 -0
- ontrack_cli-0.1.0/ontrack_cli/formatter.py +153 -0
- ontrack_cli-0.1.0/ontrack_cli/models.py +214 -0
- ontrack_cli-0.1.0/ontrack_cli/output.py +19 -0
- ontrack_cli-0.1.0/pyproject.toml +37 -0
- ontrack_cli-0.1.0/release-notes/v0.1.0.md +41 -0
- ontrack_cli-0.1.0/tests/conftest.py +7 -0
- ontrack_cli-0.1.0/tests/test_cli.py +121 -0
- ontrack_cli-0.1.0/tests/test_config.py +99 -0
- ontrack_cli-0.1.0/uv.lock +572 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["**"]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_call:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
name: Test (Python ${{ matrix.python-version }})
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Set up uv
|
|
26
|
+
uses: astral-sh/setup-uv@v6
|
|
27
|
+
|
|
28
|
+
- name: Set up Python
|
|
29
|
+
uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: ${{ matrix.python-version }}
|
|
32
|
+
|
|
33
|
+
- name: Sync dependencies
|
|
34
|
+
run: uv sync --locked
|
|
35
|
+
|
|
36
|
+
- name: Run tests
|
|
37
|
+
run: uv run pytest -q
|
|
38
|
+
|
|
39
|
+
- name: Compile package
|
|
40
|
+
run: uv run python -m compileall ontrack_cli
|
|
41
|
+
|
|
42
|
+
- name: Smoke test CLI
|
|
43
|
+
run: uv run ontrack --help
|
|
44
|
+
|
|
45
|
+
build:
|
|
46
|
+
name: Build distribution
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
steps:
|
|
49
|
+
- name: Checkout
|
|
50
|
+
uses: actions/checkout@v4
|
|
51
|
+
|
|
52
|
+
- name: Set up uv
|
|
53
|
+
uses: astral-sh/setup-uv@v6
|
|
54
|
+
|
|
55
|
+
- name: Set up Python
|
|
56
|
+
uses: actions/setup-python@v5
|
|
57
|
+
with:
|
|
58
|
+
python-version: "3.12"
|
|
59
|
+
|
|
60
|
+
- name: Build package
|
|
61
|
+
run: uv build
|
|
62
|
+
|
|
63
|
+
- name: Check distribution metadata
|
|
64
|
+
run: uvx twine check dist/*
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
verify:
|
|
13
|
+
uses: ./.github/workflows/ci.yml
|
|
14
|
+
|
|
15
|
+
publish:
|
|
16
|
+
needs: verify
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
environment:
|
|
19
|
+
name: pypi
|
|
20
|
+
url: https://pypi.org/project/ontrack-cli/
|
|
21
|
+
permissions:
|
|
22
|
+
id-token: write
|
|
23
|
+
contents: read
|
|
24
|
+
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
|
|
28
|
+
- uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: "3.12"
|
|
31
|
+
|
|
32
|
+
- name: Setup uv
|
|
33
|
+
uses: astral-sh/setup-uv@v6
|
|
34
|
+
|
|
35
|
+
- name: Verify tag matches package version
|
|
36
|
+
run: |
|
|
37
|
+
python - <<'PY'
|
|
38
|
+
import os
|
|
39
|
+
import pathlib
|
|
40
|
+
import tomllib
|
|
41
|
+
|
|
42
|
+
project = tomllib.loads(pathlib.Path("pyproject.toml").read_text())["project"]
|
|
43
|
+
name = project["name"]
|
|
44
|
+
version = project["version"]
|
|
45
|
+
tag = os.environ["GITHUB_REF_NAME"]
|
|
46
|
+
expected = f"v{version}"
|
|
47
|
+
if name != "ontrack-cli":
|
|
48
|
+
raise SystemExit(f"Refusing to publish unexpected package name: {name}")
|
|
49
|
+
if tag != expected:
|
|
50
|
+
raise SystemExit(f"Tag {tag} does not match package version {expected}")
|
|
51
|
+
print(f"Validated release tag {tag} for {name}")
|
|
52
|
+
PY
|
|
53
|
+
|
|
54
|
+
- name: Build package
|
|
55
|
+
run: uv build
|
|
56
|
+
|
|
57
|
+
- name: Check distribution metadata
|
|
58
|
+
run: uvx twine check dist/*
|
|
59
|
+
|
|
60
|
+
- name: Publish to PyPI
|
|
61
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Publish GitHub Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
verify:
|
|
13
|
+
uses: ./.github/workflows/ci.yml
|
|
14
|
+
|
|
15
|
+
release:
|
|
16
|
+
needs: verify
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
permissions:
|
|
19
|
+
contents: write
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- uses: actions/setup-python@v5
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.12"
|
|
27
|
+
|
|
28
|
+
- name: Setup uv
|
|
29
|
+
uses: astral-sh/setup-uv@v6
|
|
30
|
+
|
|
31
|
+
- name: Verify tag matches package version
|
|
32
|
+
run: |
|
|
33
|
+
python - <<'PY'
|
|
34
|
+
import os
|
|
35
|
+
import pathlib
|
|
36
|
+
import tomllib
|
|
37
|
+
|
|
38
|
+
project = tomllib.loads(pathlib.Path("pyproject.toml").read_text())["project"]
|
|
39
|
+
name = project["name"]
|
|
40
|
+
version = project["version"]
|
|
41
|
+
tag = os.environ["GITHUB_REF_NAME"]
|
|
42
|
+
expected = f"v{version}"
|
|
43
|
+
if name != "ontrack-cli":
|
|
44
|
+
raise SystemExit(f"Refusing to release unexpected package name: {name}")
|
|
45
|
+
if tag != expected:
|
|
46
|
+
raise SystemExit(f"Tag {tag} does not match package version {expected}")
|
|
47
|
+
print(f"Validated release tag {tag} for {name}")
|
|
48
|
+
PY
|
|
49
|
+
|
|
50
|
+
- name: Build package
|
|
51
|
+
run: uv build
|
|
52
|
+
|
|
53
|
+
- name: Publish GitHub release
|
|
54
|
+
uses: softprops/action-gh-release@v2
|
|
55
|
+
with:
|
|
56
|
+
generate_release_notes: true
|
|
57
|
+
files: |
|
|
58
|
+
dist/*.tar.gz
|
|
59
|
+
dist/*.whl
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bunizao
|
|
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.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ontrack-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Terminal-first CLI for the OnTrack/Doubtfire teaching platform
|
|
5
|
+
Project-URL: Homepage, https://github.com/bunizao/ontrack-cli
|
|
6
|
+
Project-URL: Repository, https://github.com/bunizao/ontrack-cli
|
|
7
|
+
Project-URL: Issues, https://github.com/bunizao/ontrack-cli/issues
|
|
8
|
+
Author: bunizao
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 bunizao
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Requires-Python: >=3.10
|
|
32
|
+
Requires-Dist: browser-cookie3>=0.20
|
|
33
|
+
Requires-Dist: click>=8.1
|
|
34
|
+
Requires-Dist: pyyaml>=6.0
|
|
35
|
+
Requires-Dist: requests>=2.31
|
|
36
|
+
Requires-Dist: rich>=13.7
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# ontrack-cli
|
|
40
|
+
|
|
41
|
+
Terminal-first CLI for OnTrack that reuses your authenticated browser session.
|
|
42
|
+
|
|
43
|
+
`ontrack-cli` targets Doubtfire / OnTrack deployments and is designed for quick terminal access to your projects, tasks, and teaching roles without building a separate login flow.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- No manual API token setup in the common case
|
|
48
|
+
- Reads browser auth state from Chrome, Firefox, Brave, or Edge when available
|
|
49
|
+
- Prompts for `base_url` on first run and saves it like `moodle-cli`
|
|
50
|
+
- Lists projects, merged task views, and teaching roles
|
|
51
|
+
- Supports terminal output plus `--json` and `--yaml`
|
|
52
|
+
|
|
53
|
+
## Requirements
|
|
54
|
+
|
|
55
|
+
- Python 3.10+
|
|
56
|
+
- `uv` or `pipx`
|
|
57
|
+
- An authenticated OnTrack browser session, or explicit credentials
|
|
58
|
+
|
|
59
|
+
## Install
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Recommended: uv tool
|
|
63
|
+
uv tool install ontrack-cli
|
|
64
|
+
|
|
65
|
+
# Alternative: pipx
|
|
66
|
+
pipx install ontrack-cli
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Install from source:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git clone https://github.com/bunizao/ontrack-cli.git
|
|
73
|
+
cd ontrack-cli
|
|
74
|
+
uv sync
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Usage
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
ontrack --help
|
|
81
|
+
ontrack user
|
|
82
|
+
ontrack auth check
|
|
83
|
+
ontrack projects
|
|
84
|
+
ontrack project 12345
|
|
85
|
+
ontrack tasks 12345
|
|
86
|
+
ontrack roles
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Structured output:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
ontrack projects --json
|
|
93
|
+
ontrack project 12345 --yaml
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
To upgrade after a new release:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
uv tool upgrade ontrack-cli
|
|
100
|
+
# or
|
|
101
|
+
pipx upgrade ontrack-cli
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Configuration
|
|
105
|
+
|
|
106
|
+
On first run, if no `base_url` is configured, the CLI prompts for it and writes it to `config.yaml` in the project directory or in `~/.config/ontrack-cli/`:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
base_url: https://school.example.edu
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Required format:
|
|
113
|
+
|
|
114
|
+
- Use a full root URL such as `https://school.example.edu`
|
|
115
|
+
- Do not include paths, query strings, or fragments
|
|
116
|
+
- Do not use URLs like `/home`, `/#/projects`, or `/api/auth`
|
|
117
|
+
- The CLI validates the URL against `/api/auth/method` and asks again if it does not look like an OnTrack site
|
|
118
|
+
|
|
119
|
+
You can also set `ONTRACK_BASE_URL` instead of using the interactive prompt.
|
|
120
|
+
You can copy from [config.example.yaml](config.example.yaml).
|
|
121
|
+
|
|
122
|
+
Environment overrides:
|
|
123
|
+
|
|
124
|
+
- `ONTRACK_BASE_URL`
|
|
125
|
+
- `ONTRACK_USERNAME`
|
|
126
|
+
- `ONTRACK_AUTH_TOKEN`
|
|
127
|
+
- `ONTRACK_DOUBTFIRE_USER_JSON`
|
|
128
|
+
|
|
129
|
+
## Authentication
|
|
130
|
+
|
|
131
|
+
Default behavior:
|
|
132
|
+
|
|
133
|
+
1. Resolve `base_url`
|
|
134
|
+
2. Try browser cookies
|
|
135
|
+
3. Exchange OnTrack's browser `refresh_token` for an API auth token when supported
|
|
136
|
+
4. Fall back to explicit environment variables or config values
|
|
137
|
+
|
|
138
|
+
If browser auto-auth does not work, you can still provide credentials manually:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
export ONTRACK_BASE_URL='https://school.example.edu'
|
|
142
|
+
export ONTRACK_USERNAME='your_username'
|
|
143
|
+
export ONTRACK_AUTH_TOKEN='your_auth_token'
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
You can also reuse the front-end cached user object:
|
|
147
|
+
|
|
148
|
+
1. Open an authenticated OnTrack page
|
|
149
|
+
2. Open DevTools Console
|
|
150
|
+
3. Run:
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
copy(localStorage.getItem('doubtfire_user'))
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
4. Export it:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
export ONTRACK_DOUBTFIRE_USER_JSON='{"id":123,"username":"your_username","authenticationToken":"..."}'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Commands
|
|
163
|
+
|
|
164
|
+
- `ontrack user`: show the resolved signed-in user
|
|
165
|
+
- `ontrack auth check`: validate access and show a quick auth summary
|
|
166
|
+
- `ontrack projects`: list the current user's projects
|
|
167
|
+
- `ontrack project <project_id>`: show a project with merged task definition metadata
|
|
168
|
+
- `ontrack tasks <project_id>`: list task rows for a project
|
|
169
|
+
- `ontrack roles`: list teaching roles for the current user
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
uv run pytest -q
|
|
175
|
+
uv run python -m compileall ontrack_cli
|
|
176
|
+
uv build
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Notes
|
|
180
|
+
|
|
181
|
+
- The CLI is built around Doubtfire / OnTrack API behavior
|
|
182
|
+
- Browser-based auto-auth works best when you are already signed in to the target site
|
|
183
|
+
- Some deployments expose `POST /api/auth/access-token`, which allows clean browser-session reuse
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# ontrack-cli
|
|
2
|
+
|
|
3
|
+
Terminal-first CLI for OnTrack that reuses your authenticated browser session.
|
|
4
|
+
|
|
5
|
+
`ontrack-cli` targets Doubtfire / OnTrack deployments and is designed for quick terminal access to your projects, tasks, and teaching roles without building a separate login flow.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- No manual API token setup in the common case
|
|
10
|
+
- Reads browser auth state from Chrome, Firefox, Brave, or Edge when available
|
|
11
|
+
- Prompts for `base_url` on first run and saves it like `moodle-cli`
|
|
12
|
+
- Lists projects, merged task views, and teaching roles
|
|
13
|
+
- Supports terminal output plus `--json` and `--yaml`
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Python 3.10+
|
|
18
|
+
- `uv` or `pipx`
|
|
19
|
+
- An authenticated OnTrack browser session, or explicit credentials
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Recommended: uv tool
|
|
25
|
+
uv tool install ontrack-cli
|
|
26
|
+
|
|
27
|
+
# Alternative: pipx
|
|
28
|
+
pipx install ontrack-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Install from source:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone https://github.com/bunizao/ontrack-cli.git
|
|
35
|
+
cd ontrack-cli
|
|
36
|
+
uv sync
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
ontrack --help
|
|
43
|
+
ontrack user
|
|
44
|
+
ontrack auth check
|
|
45
|
+
ontrack projects
|
|
46
|
+
ontrack project 12345
|
|
47
|
+
ontrack tasks 12345
|
|
48
|
+
ontrack roles
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Structured output:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
ontrack projects --json
|
|
55
|
+
ontrack project 12345 --yaml
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
To upgrade after a new release:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
uv tool upgrade ontrack-cli
|
|
62
|
+
# or
|
|
63
|
+
pipx upgrade ontrack-cli
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Configuration
|
|
67
|
+
|
|
68
|
+
On first run, if no `base_url` is configured, the CLI prompts for it and writes it to `config.yaml` in the project directory or in `~/.config/ontrack-cli/`:
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
base_url: https://school.example.edu
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Required format:
|
|
75
|
+
|
|
76
|
+
- Use a full root URL such as `https://school.example.edu`
|
|
77
|
+
- Do not include paths, query strings, or fragments
|
|
78
|
+
- Do not use URLs like `/home`, `/#/projects`, or `/api/auth`
|
|
79
|
+
- The CLI validates the URL against `/api/auth/method` and asks again if it does not look like an OnTrack site
|
|
80
|
+
|
|
81
|
+
You can also set `ONTRACK_BASE_URL` instead of using the interactive prompt.
|
|
82
|
+
You can copy from [config.example.yaml](config.example.yaml).
|
|
83
|
+
|
|
84
|
+
Environment overrides:
|
|
85
|
+
|
|
86
|
+
- `ONTRACK_BASE_URL`
|
|
87
|
+
- `ONTRACK_USERNAME`
|
|
88
|
+
- `ONTRACK_AUTH_TOKEN`
|
|
89
|
+
- `ONTRACK_DOUBTFIRE_USER_JSON`
|
|
90
|
+
|
|
91
|
+
## Authentication
|
|
92
|
+
|
|
93
|
+
Default behavior:
|
|
94
|
+
|
|
95
|
+
1. Resolve `base_url`
|
|
96
|
+
2. Try browser cookies
|
|
97
|
+
3. Exchange OnTrack's browser `refresh_token` for an API auth token when supported
|
|
98
|
+
4. Fall back to explicit environment variables or config values
|
|
99
|
+
|
|
100
|
+
If browser auto-auth does not work, you can still provide credentials manually:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
export ONTRACK_BASE_URL='https://school.example.edu'
|
|
104
|
+
export ONTRACK_USERNAME='your_username'
|
|
105
|
+
export ONTRACK_AUTH_TOKEN='your_auth_token'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
You can also reuse the front-end cached user object:
|
|
109
|
+
|
|
110
|
+
1. Open an authenticated OnTrack page
|
|
111
|
+
2. Open DevTools Console
|
|
112
|
+
3. Run:
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
copy(localStorage.getItem('doubtfire_user'))
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
4. Export it:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
export ONTRACK_DOUBTFIRE_USER_JSON='{"id":123,"username":"your_username","authenticationToken":"..."}'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Commands
|
|
125
|
+
|
|
126
|
+
- `ontrack user`: show the resolved signed-in user
|
|
127
|
+
- `ontrack auth check`: validate access and show a quick auth summary
|
|
128
|
+
- `ontrack projects`: list the current user's projects
|
|
129
|
+
- `ontrack project <project_id>`: show a project with merged task definition metadata
|
|
130
|
+
- `ontrack tasks <project_id>`: list task rows for a project
|
|
131
|
+
- `ontrack roles`: list teaching roles for the current user
|
|
132
|
+
|
|
133
|
+
## Development
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
uv run pytest -q
|
|
137
|
+
uv run python -m compileall ontrack_cli
|
|
138
|
+
uv build
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Notes
|
|
142
|
+
|
|
143
|
+
- The CLI is built around Doubtfire / OnTrack API behavior
|
|
144
|
+
- Browser-based auto-auth works best when you are already signed in to the target site
|
|
145
|
+
- Some deployments expose `POST /api/auth/access-token`, which allows clean browser-session reuse
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
base_url: https://school.example.edu
|
|
2
|
+
|
|
3
|
+
# Option 1: usually leave credentials unset and let the CLI read browser cookies.
|
|
4
|
+
|
|
5
|
+
# Option 2: paste the exact browser localStorage value from doubtfire_user.
|
|
6
|
+
# doubtfire_user_json: '{"id":123,"username":"your_username","authenticationToken":"..."}'
|
|
7
|
+
|
|
8
|
+
# Option 3: provide the fields directly.
|
|
9
|
+
# username: your_username
|
|
10
|
+
# auth_token: your_auth_token
|