Skip to content

Commit 47865d6

Browse files
committed
feat: implement core function of run_flow_pipeline
1 parent 1ff87aa commit 47865d6

File tree

2 files changed

+97
-37
lines changed

2 files changed

+97
-37
lines changed

.claude/plan/34-zerv-flow-implementation-steps.md

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030

3131
### 🔄 **Next Steps:**
3232

33-
- **Phase 2**: Implement branch pattern system and flow-to-version translation logic
34-
- **Phase 3**: Complete pipeline assembly with actual version command integration
35-
- **Phase 4**: Comprehensive testing and documentation
33+
- **Phase 2**: Implement basic flow pipeline structure with version command integration (IN PROGRESS)
34+
- **Phase 3**: Add branch pattern system and flow-to-version translation logic
35+
- **Phase 4**: Complete pipeline assembly and comprehensive testing
3636

3737
## Goals
3838

@@ -94,9 +94,36 @@
9494
- ✅ Add proper error propagation in dispatch
9595
- **Validation**: ✅ `zerv flow --help` shows all arguments correctly
9696

97-
### Phase 2: Flow Logic as Translation Layer
97+
### Phase 2: Basic Flow Pipeline Implementation
98+
99+
#### Step 4: Implement Basic run_flow_pipeline Structure 🔄
100+
101+
- **File**: `src/cli/flow/pipeline.rs` (update existing file)
102+
- **Tasks**:
103+
- 🔄 Implement basic `run_flow_pipeline()` function structure
104+
- 🔄 Call `zerv version --output-format zerv` using existing version pipeline
105+
- 🔄 Parse RON output to Zerv object using existing parsing logic
106+
- 🔄 Use `OutputFormatter::format_output()` for consistent output formatting
107+
- 🔄 Keep it simple - no argument translation yet, just basic version call
108+
- 🔄 Return formatted string result like version pipeline
109+
- **TODO**: Fix import paths and error types for compilation
110+
- **Validation**: Basic flow pipeline works and returns version output
98111

99-
#### Step 4: Create Branch Pattern System
112+
#### Step 5: Create Version Command Wrapper 🔄
113+
114+
- **File**: `src/cli/flow/wrapper.rs` (new file)
115+
- **Tasks**:
116+
- 🔄 Create wrapper to call existing `run_version_pipeline()` function
117+
- 🔄 Set up default `VersionArgs` with `--output-format zerv` for RON output
118+
- 🔄 Parse returned RON string into `Zerv` object using existing deserialization
119+
- **TODO**: Fix import path to `crate::version::zerv::core::Zerv`
120+
- **TODO**: Fix error type for deserialization errors
121+
- 🔄 Reuse all existing version logic - no duplication
122+
- **Validation**: Wrapper successfully calls version command and returns Zerv object
123+
124+
### Phase 3: Flow Logic as Translation Layer
125+
126+
#### Step 6: Create Branch Pattern System
100127

101128
- **File**: `src/cli/flow/branch_rules.rs` (new file)
102129
- **Tasks**:
@@ -108,7 +135,7 @@
108135
- Keep it simple - just pattern matching and rule lookup
109136
- **Validation**: Pattern matching works correctly for branch detection
110137

111-
#### Step 5: Create Flow-to-Version Translation Logic
138+
#### Step 7: Create Flow-to-Version Translation Logic
112139

113140
- **File**: `src/cli/flow/translator.rs` (new file)
114141
- **Tasks**:
@@ -121,33 +148,21 @@
121148
- Keep logic minimal - just translation, no version calculation
122149
- **Validation**: Translation produces correct `VersionArgs` for all scenarios
123150

124-
#### Step 6: Create Version Command Wrapper
125-
126-
- **File**: `src/cli/flow/wrapper.rs` (new file)
127-
- **Tasks**:
128-
- Create wrapper to call existing `run_version_pipeline()` function
129-
- Support multiple version command calls if needed (like piping)
130-
- Handle conversion between flow output modes and version command options
131-
- Parse Zerv objects returned from version command for further processing
132-
- Ensure proper error handling from version command calls
133-
- Reuse all existing version logic - no duplication
134-
- **Validation**: Wrapper successfully calls version command and returns results
135-
136-
### Phase 3: Pipeline Assembly
151+
### Phase 4: Pipeline Assembly
137152

138-
#### Step 7: Assemble Flow Pipeline
153+
#### Step 8: Assemble Flow Pipeline
139154

140155
- **File**: `src/cli/flow/pipeline.rs` (continued)
141156
- **Tasks**:
142-
- Create `run_flow_pipeline(args: FlowArgs) -> Result<String, ZervError>` function
143-
- Simple pipeline: validate args → translate to version args → call version command → format output
157+
- Update `run_flow_pipeline(args: FlowArgs) -> Result<String, ZervError>` function
158+
- Complete pipeline: validate args → translate to version args → call version command → format output
144159
- Use existing `run_version_pipeline()` for all heavy lifting
145160
- Handle output mode translation (`--with-pre-release`, `--base-only`)
146161
- Keep flow logic minimal - most work delegated to version command
147162
- Add verbose output showing translation results for debugging
148163
- **Validation**: Complete flow works end-to-end using version command
149164

150-
#### Step 8: Add Argument Validation ✅
165+
#### Step 9: Add Argument Validation ✅
151166

152167
- **File**: `src/cli/flow/args/validation.rs`
153168
- **Tasks**:
@@ -160,9 +175,9 @@
160175
- ✅ Use shared validation for input/output conflicts
161176
- **Validation**: ✅ All validation scenarios work correctly
162177

163-
### Phase 4: Testing and Documentation
178+
### Phase 5: Testing and Documentation
164179

165-
#### Step 9: Add Comprehensive Test Suite
180+
#### Step 10: Add Comprehensive Test Suite
166181

167182
- **Files**:
168183
- `src/cli/flow/` - Add `#[cfg(test)] mod tests` blocks to each module
@@ -176,7 +191,7 @@
176191
- Test error scenarios and edge cases
177192
- **Validation**: All tests pass and coverage is adequate
178193

179-
#### Step 10: Update Documentation and Help Text
194+
#### Step 11: Update Documentation and Help Text
180195

181196
- **Files**:
182197
- `src/cli/flow/args.rs` - Update doc comments for help text

src/cli/flow/pipeline.rs

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
use ron::from_str;
2+
3+
use crate::cli::common::args::{
4+
InputConfig,
5+
OutputConfig,
6+
};
17
use crate::cli::flow::args::FlowArgs;
8+
use crate::cli::utils::output_formatter::OutputFormatter;
9+
use crate::cli::version::args::VersionArgs;
10+
use crate::cli::version::pipeline::run_version_pipeline;
211
use crate::error::ZervError;
12+
use crate::utils::constants::*;
313

414
/// Main flow pipeline handler
515
///
616
/// This function orchestrates the flow version generation process:
717
/// 1. Validate input arguments
8-
/// 2. Translate flow arguments to version arguments
9-
/// 3. Call version command pipeline
18+
/// 2. Call version command pipeline with zerv output format
19+
/// 3. Parse RON output to Zerv object
1020
/// 4. Format and return results
1121
pub fn run_flow_pipeline(args: FlowArgs) -> Result<String, ZervError> {
1222
tracing::debug!("Starting flow pipeline with args: {:?}", args);
@@ -15,14 +25,40 @@ pub fn run_flow_pipeline(args: FlowArgs) -> Result<String, ZervError> {
1525
let mut args = args;
1626
args.validate()?;
1727

18-
// TODO: Phase 2+ implementation
19-
// - Translate flow arguments to version arguments
20-
// - Call existing version pipeline
21-
// - Format output based on flow-specific modes
28+
// For now, just call version command with zerv output format
29+
// TODO: Phase 2+ - Translate flow arguments to version arguments
30+
let version_args = VersionArgs {
31+
input: InputConfig {
32+
source: sources::GIT.to_string(),
33+
input_format: "auto".to_string(),
34+
directory: None,
35+
},
36+
output: OutputConfig {
37+
output_format: "zerv".to_string(),
38+
output_template: None,
39+
output_prefix: None,
40+
},
41+
main: Default::default(),
42+
overrides: Default::default(),
43+
bumps: Default::default(),
44+
};
45+
46+
// Call version pipeline to get RON output
47+
let ron_output = run_version_pipeline(version_args)?;
48+
49+
// Parse RON output to Zerv object
50+
let zerv_object: crate::version::zerv::core::Zerv = from_str(&ron_output)
51+
.map_err(|e| ZervError::InvalidFormat(format!("Failed to parse version output: {}", e)))?;
2252

23-
Err(ZervError::NotImplemented(
24-
"Flow pipeline translation and execution not yet implemented".to_string(),
25-
))
53+
// Format output using the same formatter as version command
54+
let output = OutputFormatter::format_output(
55+
&zerv_object,
56+
&args.output.output_format,
57+
args.output.output_prefix.as_deref(),
58+
&args.output.output_template,
59+
)?;
60+
61+
Ok(output)
2662
}
2763

2864
#[cfg(test)]
@@ -33,8 +69,17 @@ mod tests {
3369
fn test_run_flow_pipeline_basic() {
3470
let args = FlowArgs::default();
3571
let result = run_flow_pipeline(args);
36-
assert!(result.is_err());
37-
assert!(matches!(result.unwrap_err(), ZervError::NotImplemented(_)));
72+
// Should work now (assuming git repo exists)
73+
// Note: This test may fail in environments without git
74+
match result {
75+
Ok(_) => {} // Success
76+
Err(ZervError::VcsNotFound(_)) => {
77+
// Expected in test environments without git
78+
}
79+
Err(e) => {
80+
panic!("Unexpected error: {:?}", e);
81+
}
82+
}
3883
}
3984

4085
#[test]

0 commit comments

Comments
 (0)