Skip to content

Commit df8928d

Browse files
committed
feat: Aggiungi flag --version/-v alla CLI per mostrare la versione del pacchetto
1 parent 9731951 commit df8928d

9 files changed

Lines changed: 155 additions & 0 deletions

File tree

.claude/commands/openspec/apply.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: OpenSpec: Apply
3+
description: Implement an approved OpenSpec change and keep tasks in sync.
4+
category: OpenSpec
5+
tags: [openspec, apply]
6+
---
7+
<!-- OPENSPEC:START -->
8+
**Guardrails**
9+
- Favor straightforward, minimal implementations first and add complexity only when it is requested or clearly required.
10+
- Keep changes tightly scoped to the requested outcome.
11+
- Refer to `openspec/AGENTS.md` (located inside the `openspec/` directory—run `ls openspec` or `openspec update` if you don't see it) if you need additional OpenSpec conventions or clarifications.
12+
13+
**Steps**
14+
Track these steps as TODOs and complete them one by one.
15+
1. Read `changes/<id>/proposal.md`, `design.md` (if present), and `tasks.md` to confirm scope and acceptance criteria.
16+
2. Work through tasks sequentially, keeping edits minimal and focused on the requested change.
17+
3. Confirm completion before updating statuses—make sure every item in `tasks.md` is finished.
18+
4. Update the checklist after all work is done so each task is marked `- [x]` and reflects reality.
19+
5. Reference `openspec list` or `openspec show <item>` when additional context is required.
20+
21+
**Reference**
22+
- Use `openspec show <id> --json --deltas-only` if you need additional context from the proposal while implementing.
23+
<!-- OPENSPEC:END -->
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: OpenSpec: Archive
3+
description: Archive a deployed OpenSpec change and update specs.
4+
category: OpenSpec
5+
tags: [openspec, archive]
6+
---
7+
<!-- OPENSPEC:START -->
8+
**Guardrails**
9+
- Favor straightforward, minimal implementations first and add complexity only when it is requested or clearly required.
10+
- Keep changes tightly scoped to the requested outcome.
11+
- Refer to `openspec/AGENTS.md` (located inside the `openspec/` directory—run `ls openspec` or `openspec update` if you don't see it) if you need additional OpenSpec conventions or clarifications.
12+
13+
**Steps**
14+
1. Determine the change ID to archive:
15+
- If this prompt already includes a specific change ID (for example inside a `<ChangeId>` block populated by slash-command arguments), use that value after trimming whitespace.
16+
- If the conversation references a change loosely (for example by title or summary), run `openspec list` to surface likely IDs, share the relevant candidates, and confirm which one the user intends.
17+
- Otherwise, review the conversation, run `openspec list`, and ask the user which change to archive; wait for a confirmed change ID before proceeding.
18+
- If you still cannot identify a single change ID, stop and tell the user you cannot archive anything yet.
19+
2. Validate the change ID by running `openspec list` (or `openspec show <id>`) and stop if the change is missing, already archived, or otherwise not ready to archive.
20+
3. Run `openspec archive <id> --yes` so the CLI moves the change and applies spec updates without prompts (use `--skip-specs` only for tooling-only work).
21+
4. Review the command output to confirm the target specs were updated and the change landed in `changes/archive/`.
22+
5. Validate with `openspec validate --strict` and inspect with `openspec show <id>` if anything looks off.
23+
24+
**Reference**
25+
- Use `openspec list` to confirm change IDs before archiving.
26+
- Inspect refreshed specs with `openspec list --specs` and address any validation issues before handing off.
27+
<!-- OPENSPEC:END -->
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: OpenSpec: Proposal
3+
description: Scaffold a new OpenSpec change and validate strictly.
4+
category: OpenSpec
5+
tags: [openspec, change]
6+
---
7+
<!-- OPENSPEC:START -->
8+
**Guardrails**
9+
- Favor straightforward, minimal implementations first and add complexity only when it is requested or clearly required.
10+
- Keep changes tightly scoped to the requested outcome.
11+
- Refer to `openspec/AGENTS.md` (located inside the `openspec/` directory—run `ls openspec` or `openspec update` if you don't see it) if you need additional OpenSpec conventions or clarifications.
12+
- Identify any vague or ambiguous details and ask the necessary follow-up questions before editing files.
13+
14+
**Steps**
15+
1. Review `openspec/project.md`, run `openspec list` and `openspec list --specs`, and inspect related code or docs (e.g., via `rg`/`ls`) to ground the proposal in current behaviour; note any gaps that require clarification.
16+
2. Choose a unique verb-led `change-id` and scaffold `proposal.md`, `tasks.md`, and `design.md` (when needed) under `openspec/changes/<id>/`.
17+
3. Map the change into concrete capabilities or requirements, breaking multi-scope efforts into distinct spec deltas with clear relationships and sequencing.
18+
4. Capture architectural reasoning in `design.md` when the solution spans multiple systems, introduces new patterns, or demands trade-off discussion before committing to specs.
19+
5. Draft spec deltas in `changes/<id>/specs/<capability>/spec.md` (one folder per capability) using `## ADDED|MODIFIED|REMOVED Requirements` with at least one `#### Scenario:` per requirement and cross-reference related capabilities when relevant.
20+
6. Draft `tasks.md` as an ordered list of small, verifiable work items that deliver user-visible progress, include validation (tests, tooling), and highlight dependencies or parallelizable work.
21+
7. Validate with `openspec validate <id> --strict` and resolve every issue before sharing the proposal.
22+
23+
**Reference**
24+
- Use `openspec show <id> --json --deltas-only` or `openspec show <spec> --type spec` to inspect details when validation fails.
25+
- Search existing requirements with `rg -n "Requirement:|Scenario:" openspec/specs` before writing new ones.
26+
- Explore the codebase with `rg <keyword>`, `ls`, or direct file reads so proposals align with current implementation realities.
27+
<!-- OPENSPEC:END -->

LOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
Questo file documenta gli avanzamenti significativi e le decisioni chiave del progetto `normattiva_2_md`.
44

5+
## 2025-11-02
6+
7+
### ✅ Aggiunto flag --version/-v
8+
9+
- Implementato flag CLI per mostrare versione pacchetto
10+
- Argparse action='version' con VERSION constant
11+
- Exit automatico senza conversione
12+
- Tests: flag lungo, corto, precedenza su input
13+
514
## 2025-01-11
615

716
### 🔒 Release v1.4.2: Security Hardening

convert_akomantoso.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,9 @@ def main():
893893
"""
894894
)
895895

896+
# Version flag
897+
parser.add_argument('-v', '--version', action='version', version=f'%(prog)s {VERSION}')
898+
896899
# Argomenti posizionali (compatibilità con uso semplice)
897900
parser.add_argument('input', nargs='?',
898901
help='File XML locale o URL normattiva.it')
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Why
2+
3+
Users need to check which version of akoma2md is installed for debugging, compatibility verification, and reporting issues.
4+
5+
## What Changes
6+
7+
- Add `--version` and `-v` flags to CLI
8+
- Display version from package metadata
9+
- Exit after showing version (no conversion)
10+
11+
## Impact
12+
13+
- Affected specs: markdown-conversion
14+
- Affected code: convert_akomantoso.py (argparse configuration)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## ADDED Requirements
2+
3+
### Requirement: Version Flag
4+
5+
The system SHALL provide `--version` and `-v` flags to display the installed package version.
6+
7+
#### Scenario: Display version with long flag
8+
9+
- **WHEN** user runs `akoma2md --version`
10+
- **THEN** the tool SHALL print the version number from package metadata
11+
- **AND** exit without performing conversion
12+
13+
#### Scenario: Display version with short flag
14+
15+
- **WHEN** user runs `akoma2md -v`
16+
- **THEN** the tool SHALL print the version number from package metadata
17+
- **AND** exit without performing conversion
18+
19+
#### Scenario: Version flag takes precedence
20+
21+
- **WHEN** user runs `akoma2md --version input.xml`
22+
- **THEN** the tool SHALL display version and exit
23+
- **AND** no conversion SHALL be attempted
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## 1. Implementation
2+
3+
- [x] 1.1 Add version argument to argparse with action='version'
4+
- [x] 1.2 Extract version from package metadata using importlib.metadata
5+
- [x] 1.3 Test --version flag displays correct version
6+
- [x] 1.4 Test -v short flag works identically
7+
- [x] 1.5 Verify version display exits without processing

openspec/specs/markdown-conversion/spec.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,25 @@ The system SHALL extract document metadata from Akoma Ntoso XML meta sections an
4343
- **WHEN** processing normattiva.it URLs
4444
- **THEN** metadata SHALL be extracted from URL parameters as fallback
4545

46+
### Requirement: Version Flag
47+
48+
The system SHALL provide `--version` and `-v` flags to display the installed package version.
49+
50+
#### Scenario: Display version with long flag
51+
52+
- **WHEN** user runs `akoma2md --version`
53+
- **THEN** the tool SHALL print the version number from package metadata
54+
- **AND** exit without performing conversion
55+
56+
#### Scenario: Display version with short flag
57+
58+
- **WHEN** user runs `akoma2md -v`
59+
- **THEN** the tool SHALL print the version number from package metadata
60+
- **AND** exit without performing conversion
61+
62+
#### Scenario: Version flag takes precedence
63+
64+
- **WHEN** user runs `akoma2md --version input.xml`
65+
- **THEN** the tool SHALL display version and exit
66+
- **AND** no conversion SHALL be attempted
67+

0 commit comments

Comments
 (0)