Skip to content

Commit efaecd4

Browse files
committed
docs(trlc): Document version-field parameter and behavior
Issue: SWF-23949
1 parent 0fd4118 commit efaecd4

2 files changed

Lines changed: 67 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
### 1.0.3-dev
77

8+
* `lobster-trlc`:
9+
- Updated documentation to explain how to use the version flag (`version-field`) parameter
10+
in conversion rules and how it affects generated versioned tags.
11+
812
* `lobster-json`:
913
- Fixed crash when processing empty JSON files. The tool now exits gracefully with
1014
return code 1 and prints a proper error message to stderr: "Input file contains invalid JSON."

packages/lobster-tool-trlc/README.md

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ inputs:
2626
- potato.trlc
2727

2828
conversion-rules:
29-
- package: vegtables
29+
- package: vegetables
3030
record-type: Requirement
3131
namespace: req
3232
description-fields:
@@ -42,7 +42,7 @@ conversion-rules:
4242
tags:
4343
- derived_from
4444
applies-to-derived-types: true
45-
- package: vegtables
45+
- package: vegetables
4646
record-type: Security_Requirement
4747
namespace: req
4848
description-fields:
@@ -53,10 +53,9 @@ conversion-rules:
5353
namespace: act
5454

5555
to-string-rules:
56-
- package: vegtables
57-
tuple_type: External_Id
58-
namespace: req
59-
to_string:
56+
- package: vegetables
57+
tuple-type: External_Id
58+
to-string:
6059
- "$(item)@$(version)"
6160
- "$(item)"
6261
```
@@ -67,6 +66,59 @@ like this marks this type (and all its extensions) as things to trace.
6766
The `description-fields` specify which fields carry the description text that
6867
can be optionally included in LOBSTER.
6968

69+
### Version parameter (`version-field`)
70+
71+
Use `version-field` inside a `conversion-rules` entry to select which TRLC
72+
record field is written as the generated LOBSTER item version.
73+
74+
Some teams call this a "version flag" in prose, but the exact configuration
75+
key is `version-field`.
76+
77+
Example:
78+
79+
```yaml
80+
conversion-rules:
81+
- package: vegetables
82+
record-type: Requirement
83+
namespace: req
84+
version-field: p_version
85+
```
86+
87+
Behavior:
88+
89+
- **Configured and field exists:** If `version-field` is configured and the record object
90+
contains a field with that name, the tool sets the tag version to that field's value.
91+
- **Configured but field missing:** If `version-field` is configured but the record object
92+
does not contain a field with that name, the tool sets the tag version to `None`.
93+
- **Not configured:** If no `version-field` entry is present in the conversion rule,
94+
the tool sets the tag version to `None` regardless of the record object.
95+
96+
When `to-string-rules` contain expressions like `$(item)@$(version)`, the version value
97+
(whether set or `None`) is used to build versioned tags or their fallback alternatives.
98+
99+
Complete example (versioned tag preferred, fallback without version):
100+
101+
```yaml
102+
to-string-rules:
103+
- package: vegetables
104+
tuple-type: External_Id
105+
to-string:
106+
- "$(item)@$(version)"
107+
- "$(item)"
108+
109+
conversion-rules:
110+
- package: vegetables
111+
record-type: Requirement
112+
namespace: req
113+
version-field: p_version
114+
tags:
115+
- external_id
116+
```
117+
118+
In this example, if `p_version` exists in the TRLC record,
119+
`$(item)@$(version)` is used. If `p_version` is missing, the first expansion
120+
cannot be fully applied and the fallback `$(item)` is used.
121+
70122
The `tags` field identifies the field carrying tags.
71123
In LOBSTER all tags are namespaced, and by default the namespace is "req" as that
72124
is generally what you want to do with TRLC.
@@ -120,12 +172,13 @@ tracing policy will be validated at all when considering this object.
120172

121173
## Executing lobster-trlc tool
122174

123-
`lobster-trlc` takes two command line arguments as follows:
124-
* `--config` - Yaml based config file path in which the following parameters can be
175+
`lobster-trlc` takes the following command line arguments:
176+
* `--config` - YAML based config file path in which the following parameters can be
125177
mentioned.
126178
* `inputs`: A list of input file paths (can include directories).
127-
* `inputs_from_file`: A file containing paths to input files or directories.
128-
* `out`: The name of the output file where results will be stored.
179+
* `inputs-from-file`: A file containing paths to input files or directories.
180+
* `DIR|FILE` (optional positional arguments): Additional input directories or files.
181+
* `--out`: The name of the output file where results will be stored.
129182

130183
### Command
131184

0 commit comments

Comments
 (0)