tlaplus-cli 0.1.7__tar.gz → 0.2.1__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.
- tlaplus_cli-0.2.1/MANIFEST.in +4 -0
- {tlaplus_cli-0.1.7/tlaplus_cli.egg-info → tlaplus_cli-0.2.1}/PKG-INFO +89 -21
- tlaplus_cli-0.2.1/README.md +182 -0
- {tlaplus_cli-0.1.7 → tlaplus_cli-0.2.1}/pyproject.toml +6 -5
- {tlaplus_cli-0.1.7/tla → tlaplus_cli-0.2.1/src/tlaplus_cli}/build_tlc_module.py +9 -5
- {tlaplus_cli-0.1.7/tla → tlaplus_cli-0.2.1/src/tlaplus_cli}/cli.py +9 -8
- {tlaplus_cli-0.1.7/tla → tlaplus_cli-0.2.1/src/tlaplus_cli}/config.py +1 -1
- {tlaplus_cli-0.1.7/tla → tlaplus_cli-0.2.1/src/tlaplus_cli}/resources/default_config.yaml +3 -3
- tlaplus_cli-0.2.1/src/tlaplus_cli/run_tlc.py +86 -0
- {tlaplus_cli-0.1.7/tla → tlaplus_cli-0.2.1/src/tlaplus_cli}/settings.py +3 -3
- tlaplus_cli-0.2.1/src/tlaplus_cli/tlc_manager.py +310 -0
- tlaplus_cli-0.2.1/src/tlaplus_cli/version_manager.py +311 -0
- {tlaplus_cli-0.1.7 → tlaplus_cli-0.2.1/src/tlaplus_cli.egg-info}/PKG-INFO +89 -21
- tlaplus_cli-0.2.1/src/tlaplus_cli.egg-info/SOURCES.txt +28 -0
- tlaplus_cli-0.2.1/src/tlaplus_cli.egg-info/entry_points.txt +2 -0
- tlaplus_cli-0.2.1/src/tlaplus_cli.egg-info/top_level.txt +1 -0
- {tlaplus_cli-0.1.7 → tlaplus_cli-0.2.1}/tests/test_build_tlc_module.py +12 -16
- tlaplus_cli-0.2.1/tests/test_check_java.py +69 -0
- {tlaplus_cli-0.1.7 → tlaplus_cli-0.2.1}/tests/test_cli.py +1 -2
- tlaplus_cli-0.2.1/tests/test_java_module_naming.py +85 -0
- {tlaplus_cli-0.1.7 → tlaplus_cli-0.2.1}/tests/test_run_tlc.py +37 -19
- tlaplus_cli-0.2.1/tests/test_tlc_manager.py +355 -0
- tlaplus_cli-0.2.1/tests/test_version_manager.py +70 -0
- tlaplus_cli-0.1.7/MANIFEST.in +0 -4
- tlaplus_cli-0.1.7/README.md +0 -114
- tlaplus_cli-0.1.7/tests/test_check_java.py +0 -59
- tlaplus_cli-0.1.7/tests/test_download_tla2tools.py +0 -147
- tlaplus_cli-0.1.7/tla/download_tla2tools.py +0 -109
- tlaplus_cli-0.1.7/tla/run_tlc.py +0 -45
- tlaplus_cli-0.1.7/tlaplus_cli.egg-info/SOURCES.txt +0 -25
- tlaplus_cli-0.1.7/tlaplus_cli.egg-info/entry_points.txt +0 -2
- tlaplus_cli-0.1.7/tlaplus_cli.egg-info/top_level.txt +0 -1
- {tlaplus_cli-0.1.7 → tlaplus_cli-0.2.1}/LICENSE +0 -0
- {tlaplus_cli-0.1.7 → tlaplus_cli-0.2.1}/setup.cfg +0 -0
- {tlaplus_cli-0.1.7/tla → tlaplus_cli-0.2.1/src/tlaplus_cli}/__init__.py +0 -0
- {tlaplus_cli-0.1.7/tla → tlaplus_cli-0.2.1/src/tlaplus_cli}/check_java.py +0 -0
- {tlaplus_cli-0.1.7/tla → tlaplus_cli-0.2.1/src/tlaplus_cli}/py.typed +0 -0
- {tlaplus_cli-0.1.7 → tlaplus_cli-0.2.1/src}/tlaplus_cli.egg-info/dependency_links.txt +0 -0
- {tlaplus_cli-0.1.7 → tlaplus_cli-0.2.1/src}/tlaplus_cli.egg-info/requires.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tlaplus-cli
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: TLA+ tools: download TLC, compile custom modules, run model checker
|
|
5
5
|
Author-email: Denis Nikolskiy <codeomatics@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -32,10 +32,10 @@ Command-line tool for working with TLA+ specifications and the TLC model checker
|
|
|
32
32
|
|
|
33
33
|
## Installation
|
|
34
34
|
|
|
35
|
-
Install system-wide via uv tool
|
|
35
|
+
Install system-wide via uv tool:
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
uv tool install
|
|
38
|
+
uv tool install tlaplus-cli
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
Upgrade:
|
|
@@ -43,51 +43,119 @@ Upgrade:
|
|
|
43
43
|
uv tool upgrade tlaplus-cli
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
Uninstall
|
|
47
|
-
|
|
46
|
+
Uninstall:
|
|
48
47
|
```bash
|
|
49
48
|
uv tool uninstall tlaplus-cli
|
|
50
49
|
```
|
|
51
50
|
|
|
52
51
|
## Usage
|
|
53
52
|
|
|
54
|
-
###
|
|
53
|
+
### Managing TLC Versions
|
|
54
|
+
|
|
55
|
+
The `tla tlc` command group allows you to download and manage multiple versions of the TLC model checker directly from GitHub releases.
|
|
55
56
|
|
|
57
|
+
List available and installed TLC versions:
|
|
56
58
|
```bash
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
tla tlc list
|
|
60
|
+
```
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
Install the latest TLC version:
|
|
63
|
+
```bash
|
|
64
|
+
tla tlc install
|
|
62
65
|
```
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
Install a specific TLC version:
|
|
68
|
+
```bash
|
|
69
|
+
tla tlc install v1.8.0
|
|
70
|
+
```
|
|
65
71
|
|
|
72
|
+
Pin a specific version to be used by default:
|
|
66
73
|
```bash
|
|
67
|
-
tla
|
|
74
|
+
tla tlc pin v1.8.0
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Upgrade the pinned version (or a specific version) to a newer commit:
|
|
78
|
+
```bash
|
|
79
|
+
tla tlc upgrade
|
|
68
80
|
```
|
|
69
81
|
|
|
82
|
+
Show the TLC2 version string and absolute path to the pinned version's `tla2tools.jar`:
|
|
83
|
+
```bash
|
|
84
|
+
tla tlc path
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Or for a specific version:
|
|
88
|
+
```bash
|
|
89
|
+
tla tlc path v1.8.0
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Example output:
|
|
93
|
+
```text
|
|
94
|
+
TLC2 Version 2.19 of 08 August 2024 (rev: 5a47802)
|
|
95
|
+
/home/bob/.cache/tla/tlc/v1.8.0-5a47802/tla2tools.jar
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Show the TLC versions directory and all installed version directories:
|
|
99
|
+
```bash
|
|
100
|
+
tla tlc dir
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Example output:
|
|
104
|
+
```text
|
|
105
|
+
/home/bob/.cache/tla/tlc
|
|
106
|
+
v1.7.0-abc1234
|
|
107
|
+
v1.8.0-5a47802
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Uninstall a specific version (or use 'default' to remove legacy jars):
|
|
111
|
+
```bash
|
|
112
|
+
tla tlc uninstall v1.8.0
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Run TLC
|
|
116
|
+
|
|
117
|
+
Run the TLC model checker on a specification. This uses the currently pinned TLC version.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
tla run <spec_name>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
For example (runs `queue.tla`):
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
tla run queue
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
> **Note:** Starting from version `0.2.0`, the command structure has changed. To run a model, use `tla run <spec>`. For older versions (<0.2.0), the command was `tla tlc <spec>`.
|
|
130
|
+
|
|
70
131
|
### Compile Custom Java Modules
|
|
71
132
|
|
|
133
|
+
Note that modules are compiled using the pinned version of TLC.
|
|
134
|
+
|
|
135
|
+
Compile modules:
|
|
72
136
|
```bash
|
|
73
137
|
tla build
|
|
138
|
+
```
|
|
74
139
|
|
|
75
|
-
|
|
140
|
+
Verbose output:
|
|
141
|
+
```bash
|
|
76
142
|
tla build --verbose
|
|
77
143
|
```
|
|
78
144
|
|
|
79
145
|
Compiles `.java` files from `workspace/modules/` into `workspace/classes/`.
|
|
80
146
|
|
|
81
|
-
###
|
|
147
|
+
### Check Java Version
|
|
82
148
|
|
|
83
149
|
```bash
|
|
84
|
-
tla
|
|
150
|
+
tla check-java
|
|
85
151
|
```
|
|
86
152
|
|
|
87
|
-
|
|
153
|
+
### Cache Management
|
|
154
|
+
|
|
155
|
+
The CLI caches GitHub API responses for 1 hour to prevent rate limiting. To clear this cache manually:
|
|
88
156
|
|
|
89
157
|
```bash
|
|
90
|
-
tla
|
|
158
|
+
tla fetch-cache clear
|
|
91
159
|
```
|
|
92
160
|
|
|
93
161
|
## Configuration
|
|
@@ -102,10 +170,9 @@ Edit this file to set your workspace path and TLC options:
|
|
|
102
170
|
|
|
103
171
|
```yaml
|
|
104
172
|
tla:
|
|
105
|
-
jar_name: tla2tools.jar
|
|
106
173
|
urls:
|
|
107
|
-
|
|
108
|
-
|
|
174
|
+
tags: https://api.github.com/repos/tlaplus/tlaplus/tags
|
|
175
|
+
releases: https://api.github.com/repos/tlaplus/tlaplus/releases
|
|
109
176
|
|
|
110
177
|
workspace:
|
|
111
178
|
root: . # Project root (relative to CWD)
|
|
@@ -129,7 +196,8 @@ java:
|
|
|
129
196
|
| Directory | Purpose | Location |
|
|
130
197
|
|---|---|---|
|
|
131
198
|
| Config | `config.yaml` | `~/.config/tla/` |
|
|
132
|
-
|
|
|
199
|
+
| TLC Versions | Version dirs & `tlc-pinned-version.txt` file | `~/.cache/tla/tlc/` |
|
|
200
|
+
| API Cache | `github_cache.json` | `~/.cache/tla/` |
|
|
133
201
|
| Workspace | specs + modules + classes | Set via `workspace.root` in config |
|
|
134
202
|
|
|
135
203
|
## Note on Package Name
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# TLA+ CLI
|
|
2
|
+
|
|
3
|
+
Command-line tool for working with TLA+ specifications and the TLC model checker.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install system-wide via uv tool:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uv tool install tlaplus-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Upgrade:
|
|
14
|
+
```bash
|
|
15
|
+
uv tool upgrade tlaplus-cli
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Uninstall:
|
|
19
|
+
```bash
|
|
20
|
+
uv tool uninstall tlaplus-cli
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Managing TLC Versions
|
|
26
|
+
|
|
27
|
+
The `tla tlc` command group allows you to download and manage multiple versions of the TLC model checker directly from GitHub releases.
|
|
28
|
+
|
|
29
|
+
List available and installed TLC versions:
|
|
30
|
+
```bash
|
|
31
|
+
tla tlc list
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Install the latest TLC version:
|
|
35
|
+
```bash
|
|
36
|
+
tla tlc install
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Install a specific TLC version:
|
|
40
|
+
```bash
|
|
41
|
+
tla tlc install v1.8.0
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Pin a specific version to be used by default:
|
|
45
|
+
```bash
|
|
46
|
+
tla tlc pin v1.8.0
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Upgrade the pinned version (or a specific version) to a newer commit:
|
|
50
|
+
```bash
|
|
51
|
+
tla tlc upgrade
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Show the TLC2 version string and absolute path to the pinned version's `tla2tools.jar`:
|
|
55
|
+
```bash
|
|
56
|
+
tla tlc path
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or for a specific version:
|
|
60
|
+
```bash
|
|
61
|
+
tla tlc path v1.8.0
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Example output:
|
|
65
|
+
```text
|
|
66
|
+
TLC2 Version 2.19 of 08 August 2024 (rev: 5a47802)
|
|
67
|
+
/home/bob/.cache/tla/tlc/v1.8.0-5a47802/tla2tools.jar
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Show the TLC versions directory and all installed version directories:
|
|
71
|
+
```bash
|
|
72
|
+
tla tlc dir
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Example output:
|
|
76
|
+
```text
|
|
77
|
+
/home/bob/.cache/tla/tlc
|
|
78
|
+
v1.7.0-abc1234
|
|
79
|
+
v1.8.0-5a47802
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Uninstall a specific version (or use 'default' to remove legacy jars):
|
|
83
|
+
```bash
|
|
84
|
+
tla tlc uninstall v1.8.0
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Run TLC
|
|
88
|
+
|
|
89
|
+
Run the TLC model checker on a specification. This uses the currently pinned TLC version.
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
tla run <spec_name>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For example (runs `queue.tla`):
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
tla run queue
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
> **Note:** Starting from version `0.2.0`, the command structure has changed. To run a model, use `tla run <spec>`. For older versions (<0.2.0), the command was `tla tlc <spec>`.
|
|
102
|
+
|
|
103
|
+
### Compile Custom Java Modules
|
|
104
|
+
|
|
105
|
+
Note that modules are compiled using the pinned version of TLC.
|
|
106
|
+
|
|
107
|
+
Compile modules:
|
|
108
|
+
```bash
|
|
109
|
+
tla build
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Verbose output:
|
|
113
|
+
```bash
|
|
114
|
+
tla build --verbose
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Compiles `.java` files from `workspace/modules/` into `workspace/classes/`.
|
|
118
|
+
|
|
119
|
+
### Check Java Version
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
tla check-java
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Cache Management
|
|
126
|
+
|
|
127
|
+
The CLI caches GitHub API responses for 1 hour to prevent rate limiting. To clear this cache manually:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
tla fetch-cache clear
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Configuration
|
|
134
|
+
|
|
135
|
+
On first run, a default config is created at:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
~/.config/tla/config.yaml
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Edit this file to set your workspace path and TLC options:
|
|
142
|
+
|
|
143
|
+
```yaml
|
|
144
|
+
tla:
|
|
145
|
+
urls:
|
|
146
|
+
tags: https://api.github.com/repos/tlaplus/tlaplus/tags
|
|
147
|
+
releases: https://api.github.com/repos/tlaplus/tlaplus/releases
|
|
148
|
+
|
|
149
|
+
workspace:
|
|
150
|
+
root: . # Project root (relative to CWD)
|
|
151
|
+
spec_dir: spec # Directory containing .tla files
|
|
152
|
+
modules_dir: modules # Directory containing .java files
|
|
153
|
+
classes_dir: classes # Directory for compiled .class files
|
|
154
|
+
|
|
155
|
+
tlc:
|
|
156
|
+
java_class: tlc2.TLC
|
|
157
|
+
overrides_class: tlc2.overrides.TLCOverrides
|
|
158
|
+
|
|
159
|
+
java:
|
|
160
|
+
min_version: 11
|
|
161
|
+
opts:
|
|
162
|
+
- "-XX:+IgnoreUnrecognizedVMOptions"
|
|
163
|
+
- "-XX:+UseParallelGC"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Directory Layout
|
|
167
|
+
|
|
168
|
+
| Directory | Purpose | Location |
|
|
169
|
+
|---|---|---|
|
|
170
|
+
| Config | `config.yaml` | `~/.config/tla/` |
|
|
171
|
+
| TLC Versions | Version dirs & `tlc-pinned-version.txt` file | `~/.cache/tla/tlc/` |
|
|
172
|
+
| API Cache | `github_cache.json` | `~/.cache/tla/` |
|
|
173
|
+
| Workspace | specs + modules + classes | Set via `workspace.root` in config |
|
|
174
|
+
|
|
175
|
+
## Note on Package Name
|
|
176
|
+
|
|
177
|
+
This package is distributed on PyPI as **`tlaplus-cli`** but imports as **`tla`**. There is a separate, unrelated [`tla`](https://pypi.org/project/tla/) package on PyPI (a TLA+ parser). If you have both installed, they will conflict. In practice this is unlikely since they serve different purposes, but be aware of it.
|
|
178
|
+
|
|
179
|
+
## Dependencies
|
|
180
|
+
|
|
181
|
+
* **Java >= 11**: Required for TLC.
|
|
182
|
+
* [**uv**](https://docs.astral.sh/uv/getting-started/installation/): For installing the tool.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tlaplus-cli"
|
|
7
|
-
version = "0.1
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "TLA+ tools: download TLC, compile custom modules, run model checker"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -37,13 +37,14 @@ Issues = "https://github.com/nikolskiy/tlaplus-cli/issues"
|
|
|
37
37
|
Changelog = "https://github.com/nikolskiy/tlaplus-cli/blob/main/CHANGELOG.md"
|
|
38
38
|
|
|
39
39
|
[project.scripts]
|
|
40
|
-
tla = "
|
|
40
|
+
tla = "tlaplus_cli.cli:main"
|
|
41
41
|
|
|
42
42
|
[tool.setuptools.packages.find]
|
|
43
|
-
|
|
43
|
+
where = ["src"]
|
|
44
|
+
include = ["tlaplus_cli*"]
|
|
44
45
|
|
|
45
46
|
[tool.setuptools.package-data]
|
|
46
|
-
|
|
47
|
+
tlaplus_cli = ["resources/default_config.yaml", "py.typed"]
|
|
47
48
|
|
|
48
49
|
[dependency-groups]
|
|
49
50
|
dev = [
|
|
@@ -62,7 +63,7 @@ dev = [
|
|
|
62
63
|
]
|
|
63
64
|
|
|
64
65
|
[tool.pytest.ini_options]
|
|
65
|
-
addopts = "--cov=
|
|
66
|
+
addopts = "--cov=tlaplus_cli --cov-report=term-missing"
|
|
66
67
|
testpaths = ["tests"]
|
|
67
68
|
|
|
68
69
|
[tool.ruff]
|
|
@@ -4,7 +4,8 @@ import subprocess
|
|
|
4
4
|
|
|
5
5
|
import typer
|
|
6
6
|
|
|
7
|
-
from
|
|
7
|
+
from tlaplus_cli.config import cache_dir, load_config, workspace_root
|
|
8
|
+
from tlaplus_cli.version_manager import get_pinned_version_dir
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
def build(
|
|
@@ -13,16 +14,19 @@ def build(
|
|
|
13
14
|
"""Compile custom Java modules."""
|
|
14
15
|
config = load_config()
|
|
15
16
|
|
|
16
|
-
#
|
|
17
|
-
|
|
17
|
+
# Fallback chain: pinned directory -> legacy jar
|
|
18
|
+
pinned_dir = get_pinned_version_dir()
|
|
19
|
+
pinned_jar = pinned_dir / "tla2tools.jar" if pinned_dir else None
|
|
20
|
+
legacy = cache_dir() / "tla2tools.jar"
|
|
21
|
+
jar_path = pinned_jar if (pinned_jar and pinned_jar.exists()) else legacy
|
|
18
22
|
|
|
19
23
|
ws_root = workspace_root()
|
|
20
24
|
modules_dir = ws_root / config.workspace.modules_dir
|
|
21
25
|
classes_dir = ws_root / config.workspace.classes_dir
|
|
22
26
|
|
|
23
27
|
if not jar_path.exists():
|
|
24
|
-
typer.echo(
|
|
25
|
-
typer.echo("Run 'tla
|
|
28
|
+
typer.echo("Error: tla2tools.jar not found.", err=True)
|
|
29
|
+
typer.echo("Run 'tla tlc install' first.", err=True)
|
|
26
30
|
raise typer.Exit(1)
|
|
27
31
|
|
|
28
32
|
if not modules_dir.exists():
|
|
@@ -4,11 +4,11 @@ import importlib.metadata
|
|
|
4
4
|
|
|
5
5
|
import typer
|
|
6
6
|
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
7
|
+
from tlaplus_cli.build_tlc_module import build as build_tlc_cmd
|
|
8
|
+
from tlaplus_cli.check_java import check_java_version, get_java_version
|
|
9
|
+
from tlaplus_cli.config import load_config
|
|
10
|
+
from tlaplus_cli.run_tlc import tlc as run_tlc_cmd
|
|
11
|
+
from tlaplus_cli.tlc_manager import fetch_cache_app, tlc_app
|
|
12
12
|
|
|
13
13
|
app = typer.Typer(
|
|
14
14
|
name="tla",
|
|
@@ -47,10 +47,11 @@ def root(
|
|
|
47
47
|
|
|
48
48
|
# --- Subcommands ---
|
|
49
49
|
|
|
50
|
-
#
|
|
51
|
-
app.
|
|
50
|
+
# Attach typer subgroups for TLC and fetch-cache
|
|
51
|
+
app.add_typer(tlc_app, name="tlc")
|
|
52
|
+
app.add_typer(fetch_cache_app, name="fetch-cache")
|
|
52
53
|
|
|
53
|
-
app.command(name="
|
|
54
|
+
app.command(name="run")(run_tlc_cmd)
|
|
54
55
|
app.command(name="build")(build_tlc_cmd)
|
|
55
56
|
|
|
56
57
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
tla:
|
|
2
|
-
jar_name: tla2tools.jar
|
|
3
2
|
urls:
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
tags: https://api.github.com/repos/tlaplus/tlaplus/tags
|
|
4
|
+
releases: https://api.github.com/repos/tlaplus/tlaplus/releases
|
|
5
|
+
per_page: 30
|
|
6
6
|
|
|
7
7
|
# Path to the TLA+ workspace (specs, custom modules, compiled classes).
|
|
8
8
|
# Relative paths are resolved from the current working directory.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Run TLC model checker on a TLA+ specification."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import subprocess
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
|
|
8
|
+
from tlaplus_cli.check_java import check_java_version
|
|
9
|
+
from tlaplus_cli.config import cache_dir, load_config, workspace_root
|
|
10
|
+
from tlaplus_cli.version_manager import get_pinned_version_dir
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def version_callback(value: bool) -> None:
|
|
14
|
+
if value:
|
|
15
|
+
config = load_config()
|
|
16
|
+
pinned_dir = get_pinned_version_dir()
|
|
17
|
+
pinned_jar = pinned_dir / "tla2tools.jar" if pinned_dir else None
|
|
18
|
+
legacy = cache_dir() / "tla2tools.jar"
|
|
19
|
+
jar_path = pinned_jar if (pinned_jar and pinned_jar.exists()) else legacy
|
|
20
|
+
typer.echo(f"tla2tools.jar path: {jar_path}")
|
|
21
|
+
|
|
22
|
+
if not jar_path.exists():
|
|
23
|
+
typer.echo(f"Error: tla2tools.jar not found at {jar_path}", err=True)
|
|
24
|
+
typer.echo("Run 'tla tlc install' first.", err=True)
|
|
25
|
+
raise typer.Exit(1)
|
|
26
|
+
|
|
27
|
+
cmd = ["java", "-cp", str(jar_path), config.tlc.java_class]
|
|
28
|
+
try:
|
|
29
|
+
result = subprocess.run(cmd, capture_output=True, text=True, check=False)
|
|
30
|
+
output = result.stdout or result.stderr
|
|
31
|
+
if output:
|
|
32
|
+
first_line = output.splitlines()[0]
|
|
33
|
+
typer.echo(first_line)
|
|
34
|
+
except FileNotFoundError as err:
|
|
35
|
+
typer.echo("Error: java not found.", err=True)
|
|
36
|
+
raise typer.Exit(1) from err
|
|
37
|
+
|
|
38
|
+
raise typer.Exit(0)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def tlc(
|
|
42
|
+
spec: str = typer.Argument(help="Name of the TLA+ specification (without .tla extension)."),
|
|
43
|
+
version: bool | None = typer.Option(
|
|
44
|
+
None,
|
|
45
|
+
"--version",
|
|
46
|
+
help="Print the path to tla2tools.jar and its version.",
|
|
47
|
+
callback=version_callback,
|
|
48
|
+
is_eager=True,
|
|
49
|
+
),
|
|
50
|
+
) -> None:
|
|
51
|
+
"""Run TLC model checker on a TLA+ specification."""
|
|
52
|
+
if version:
|
|
53
|
+
pass
|
|
54
|
+
config = load_config()
|
|
55
|
+
|
|
56
|
+
check_java_version(config.java.min_version)
|
|
57
|
+
|
|
58
|
+
# Fallback chain: pinned version → legacy jar
|
|
59
|
+
pinned_dir = get_pinned_version_dir()
|
|
60
|
+
pinned_jar = pinned_dir / "tla2tools.jar" if pinned_dir else None
|
|
61
|
+
legacy = cache_dir() / "tla2tools.jar"
|
|
62
|
+
jar_path = pinned_jar if (pinned_jar and pinned_jar.exists()) else legacy
|
|
63
|
+
|
|
64
|
+
if not jar_path.exists():
|
|
65
|
+
typer.echo("Error: tla2tools.jar not found.", err=True)
|
|
66
|
+
typer.echo("Run 'tla tlc install' first.", err=True)
|
|
67
|
+
raise typer.Exit(1)
|
|
68
|
+
|
|
69
|
+
ws_root = workspace_root()
|
|
70
|
+
spec_dir = ws_root / config.workspace.spec_dir
|
|
71
|
+
spec_file = spec_dir / f"{spec}.tla"
|
|
72
|
+
if not spec_file.exists():
|
|
73
|
+
typer.echo(f"Error: specification not found: {spec_file}", err=True)
|
|
74
|
+
raise typer.Exit(1)
|
|
75
|
+
|
|
76
|
+
classpath = str(jar_path)
|
|
77
|
+
classes_path = ws_root / config.workspace.classes_dir
|
|
78
|
+
if classes_path.exists():
|
|
79
|
+
classpath = f"{classes_path}{os.pathsep}{classpath}"
|
|
80
|
+
|
|
81
|
+
cmd = ["java", *config.java.opts, "-cp", classpath, config.tlc.java_class, str(spec_file)]
|
|
82
|
+
|
|
83
|
+
typer.echo(f"Running TLC on {spec}.tla ...")
|
|
84
|
+
typer.echo(f"Command: {' '.join(cmd)}")
|
|
85
|
+
result = subprocess.run(cmd, cwd=str(spec_dir))
|
|
86
|
+
raise typer.Exit(result.returncode)
|