diff options
Diffstat (limited to 'makima/src/bin/makima.rs')
| -rw-r--r-- | makima/src/bin/makima.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/makima/src/bin/makima.rs b/makima/src/bin/makima.rs index aaf5a08..c4183f3 100644 --- a/makima/src/bin/makima.rs +++ b/makima/src/bin/makima.rs @@ -810,6 +810,58 @@ async fn run_directive( let result = client .supervisor_ask(&args.question, choices, args.context, args.timeout, args.phaseguard, args.multi_select, args.non_blocking, args.question_type) .await?; + let mut response_value = result.0; + + // If the server returned still_pending, poll until we get a real response + while response_value.get("stillPending").and_then(|v| v.as_bool()).unwrap_or(false) { + // Extract question_id for polling + let question_id_str = response_value.get("questionId") + .and_then(|v| v.as_str()) + .ok_or_else(|| { + Box::<dyn std::error::Error + Send + Sync>::from( + "Missing questionId in still_pending response" + ) + })?; + let question_id: uuid::Uuid = question_id_str.parse().map_err(|e| { + Box::<dyn std::error::Error + Send + Sync>::from( + format!("Invalid questionId: {}", e) + ) + })?; + + eprintln!("Waiting for user response (polling)..."); + let poll_result = client.supervisor_poll_question(question_id).await?; + response_value = poll_result.0; + } + + println!("{}", serde_json::to_string(&response_value)?); + } + DirectiveCommand::CreateOrder(args) => { + // Validate order_type is spike or chore + if args.order_type != "spike" && args.order_type != "chore" { + eprintln!("Error: Only 'spike' and 'chore' order types are allowed. Got: '{}'", args.order_type); + std::process::exit(1); + } + let client = ApiClient::new(args.common.api_url.clone(), args.common.api_key.clone())?; + eprintln!("Creating order: {}...", args.title); + let labels = args + .labels + .map(|l| { + serde_json::Value::Array( + l.split(',') + .map(|s| serde_json::Value::String(s.trim().to_string())) + .collect(), + ) + }) + .unwrap_or_else(|| serde_json::json!([])); + let req = makima::daemon::api::supervisor::CreateOrderRequest { + title: args.title, + description: args.description, + priority: args.priority, + order_type: args.order_type, + labels, + repository_url: None, + }; + let result = client.create_order(&req).await?; println!("{}", serde_json::to_string(&result.0)?); } } |
