Skip to content

Commit dea83c9

Browse files
authored
feat: update version cli (#98)
1 parent eabecdb commit dea83c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+12177
-5292
lines changed

.cursor/rules/cli-implementation.mdc

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,79 @@ fn run_check_command(args: CheckArgs) -> Result<()> {
139139
- `--output-format <format>` - Target format: pep440, semver
140140
- `--output-template <template>` - Custom template string
141141
- `--output-prefix [prefix]` - Add prefix (defaults to "v")
142+
143+
## Constants Usage
144+
145+
**MANDATORY: Always use constants instead of bare strings**
146+
147+
### Field Names
148+
- Use `fields::MAJOR` instead of `"major"`
149+
- Use `fields::MINOR` instead of `"minor"`
150+
- Use `fields::PATCH` instead of `"patch"`
151+
- Use `fields::EPOCH` instead of `"epoch"`
152+
- Use `fields::PRE_RELEASE` instead of `"pre_release"`
153+
- Use `fields::POST` instead of `"post"`
154+
- Use `fields::DEV` instead of `"dev"`
155+
- Use `fields::DISTANCE` instead of `"distance"`
156+
- Use `fields::DIRTY` instead of `"dirty"`
157+
- Use `fields::BUMPED_BRANCH` instead of `"bumped_branch"`
158+
- Use `fields::BUMPED_COMMIT_HASH` instead of `"bumped_commit_hash"`
159+
- Use `fields::LAST_COMMIT_HASH` instead of `"last_commit_hash"`
160+
- Use `fields::LAST_TIMESTAMP` instead of `"last_timestamp"`
161+
- Use `fields::LAST_BRANCH` instead of `"last_branch"`
162+
163+
### Format Names
164+
- Use `formats::SEMVER` instead of `"semver"`
165+
- Use `formats::PEP440` instead of `"pep440"`
166+
- Use `formats::ZERV` instead of `"zerv"`
167+
- Use `formats::AUTO` instead of `"auto"`
168+
169+
### Source Names
170+
- Use `sources::GIT` instead of `"git"`
171+
- Use `sources::STDIN` instead of `"stdin"`
172+
173+
### Schema Names
174+
- Use `schema_names::ZERV_STANDARD` instead of `"zerv-standard"`
175+
- Use `schema_names::ZERV_CALVER` instead of `"zerv-calver"`
176+
177+
## Benefits of Using Constants
178+
179+
1. **Type Safety**: Compile-time checking for typos
180+
2. **Refactoring**: Easy to rename fields across codebase
181+
3. **Consistency**: Single source of truth for field names
182+
4. **IDE Support**: Better autocomplete and navigation
183+
5. **Maintenance**: Changes in one place affect all usage
184+
185+
## Anti-Patterns to Avoid
186+
187+
❌ **DON'T: Use bare strings**
188+
```rust
189+
match field_name.as_str() {
190+
"major" => // BAD
191+
"minor" => // BAD
192+
"patch" => // BAD
193+
}
194+
```
195+
196+
✅ **DO: Use constants**
197+
```rust
198+
match field_name.as_str() {
199+
fields::MAJOR => // GOOD
200+
fields::MINOR => // GOOD
201+
fields::PATCH => // GOOD
202+
}
203+
```
204+
205+
## Validation
206+
207+
When user mentions:
208+
- "check constants usage"
209+
- "find bare strings"
210+
- "audit string literals"
211+
- "constant compliance check"
212+
213+
→ Search codebase for violations:
214+
- Bare string literals in match statements
215+
- Hardcoded field names
216+
- Magic strings in validation logic
217+
- String literals that should be constants

0 commit comments

Comments
 (0)