Feature: Plan CLI commands branch coverage (round 2) As a developer I want to exercise uncovered branches in CLI command functions So that branch coverage for use_action, execute, apply, list, revert, status, correct, and diff rises # =================================================================== # use_action argument parsing – int / float / bool / string # =================================================================== Scenario: r2plan use_action parses integer argument Given r2plan-a mocked lifecycle service When r2plan-I invoke use with action "local/test" and arg "count=42" Then r2plan-the parsed arguments should have "count" as int 42 Scenario: r2plan use_action parses float argument Given r2plan-a mocked lifecycle service When r2plan-I invoke use with action "local/test" and arg "ratio=3.14" Then r2plan-the parsed arguments should have "ratio" as float 3.14 Scenario: r2plan use_action parses bool true argument Given r2plan-a mocked lifecycle service When r2plan-I invoke use with action "local/test" and arg "verbose=true" Then r2plan-the parsed arguments should have "verbose" as bool true Scenario: r2plan use_action parses bool false argument Given r2plan-a mocked lifecycle service When r2plan-I invoke use with action "local/test" and arg "verbose=false" Then r2plan-the parsed arguments should have "verbose" as bool false Scenario: r2plan use_action parses string argument Given r2plan-a mocked lifecycle service When r2plan-I invoke use with action "local/test" and arg "name=hello" Then r2plan-the parsed arguments should have "name" as string "hello" Scenario: r2plan use_action rejects argument missing equals sign Given r2plan-a mocked lifecycle service When r2plan-I invoke use with action "local/test" and arg "badarg" Then r2plan-the command should abort And r2plan-the output should contain "Invalid argument format" # =================================================================== # use_action – invalid automation profile # =================================================================== Scenario: r2plan use_action rejects invalid automation profile Given r2plan-a mocked lifecycle service When r2plan-I invoke use with action "local/test" and automation profile "bogus" Then r2plan-the command should abort And r2plan-the output should contain "Invalid automation profile" # =================================================================== # use_action – actor overrides with invalid names # =================================================================== Scenario: r2plan use_action rejects invalid strategy actor Given r2plan-a mocked lifecycle service When r2plan-I invoke use with action "local/test" and strategy actor "INVALID" Then r2plan-the command should abort And r2plan-the output should contain "Validation Error" Scenario: r2plan use_action rejects invalid execution actor Given r2plan-a mocked lifecycle service When r2plan-I invoke use with action "local/test" and execution actor "bad-name" Then r2plan-the command should abort And r2plan-the output should contain "Validation Error" # =================================================================== # execute_plan – auto-resolve: no plans / multiple plans # =================================================================== Scenario: r2plan execute_plan aborts when no plans ready Given r2plan-a mocked lifecycle service And r2plan-the service lists no complete strategize plans When r2plan-I invoke execute without plan_id Then r2plan-the command should abort And r2plan-the output should contain "No plans ready for execution" Scenario: r2plan execute_plan aborts when multiple plans ready Given r2plan-a mocked lifecycle service And r2plan-the service lists multiple complete strategize plans When r2plan-I invoke execute without plan_id Then r2plan-the command should abort And r2plan-the output should contain "Multiple plans ready" # =================================================================== # apply_plan – auto-resolve: no plans / multiple plans # =================================================================== Scenario: r2plan apply aborts when no plans ready Given r2plan-a mocked lifecycle service And r2plan-the service lists no complete execute plans When r2plan-I invoke apply without plan_id Then r2plan-the command should abort And r2plan-the output should contain "No plans ready for apply" Scenario: r2plan apply aborts when multiple plans ready Given r2plan-a mocked lifecycle service And r2plan-the service lists multiple complete execute plans When r2plan-I invoke apply without plan_id Then r2plan-the command should abort And r2plan-the output should contain "Multiple plans ready" # =================================================================== # list_plans – invalid phase / invalid state # =================================================================== Scenario: r2plan list rejects invalid phase Given r2plan-a mocked lifecycle service When r2plan-I invoke list with phase "nonexistent" Then r2plan-the command should abort And r2plan-the output should contain "Invalid phase" Scenario: r2plan list rejects invalid state Given r2plan-a mocked lifecycle service When r2plan-I invoke list with state "nonexistent" Then r2plan-the command should abort And r2plan-the output should contain "Invalid state" # =================================================================== # list_plans – empty result # =================================================================== Scenario: r2plan list shows no-plans message when empty Given r2plan-a mocked lifecycle service And r2plan-the service lists no plans When r2plan-I invoke list Then r2plan-the command should succeed And r2plan-the output should contain "No plans found" # =================================================================== # revert_plan – invalid --to-phase # =================================================================== Scenario: r2plan revert_plan rejects invalid to-phase Given r2plan-a mocked lifecycle service When r2plan-I invoke revert with plan "PLAN123" and invalid phase "badphase" Then r2plan-the command should abort And r2plan-the output should contain "Invalid phase" Scenario: r2plan revert_plan non-rich format Given r2plan-a mocked lifecycle service And r2plan-the service can revert a plan When r2plan-I invoke revert with plan "PLAN123" and format "json" Then r2plan-the command should succeed And r2plan-the output should contain "plan_id" # =================================================================== # plan_status – without plan_id: no plans, plans in non-rich, rich # =================================================================== Scenario: r2plan status shows no-plans message Given r2plan-a mocked lifecycle service And r2plan-the service lists no plans When r2plan-I invoke status without plan_id Then r2plan-the command should succeed And r2plan-the output should contain "No v3 lifecycle plans found" Scenario: r2plan status without plan_id lists plans in non-rich Given r2plan-a mocked lifecycle service And r2plan-the service lists some plans When r2plan-I invoke status without plan_id and format "json" Then r2plan-the command should succeed And r2plan-the output should contain "plan_id" Scenario: r2plan status with plan_id in non-rich format Given r2plan-a mocked lifecycle service And r2plan-the service can get a plan by id When r2plan-I invoke status with plan_id and format "json" Then r2plan-the command should succeed And r2plan-the output should contain "plan_id" # =================================================================== # correct_decision – invalid mode / empty guidance # =================================================================== Scenario: r2plan correct rejects invalid mode Given r2plan-a mocked lifecycle service When r2plan-I invoke correct with mode "badmode" Then r2plan-the command should abort And r2plan-the output should contain "Invalid mode" Scenario: r2plan correct rejects empty guidance Given r2plan-a mocked lifecycle service When r2plan-I invoke correct with empty guidance Then r2plan-the command should abort And r2plan-the output should contain "guidance" # =================================================================== # plan_diff – correction flag present # =================================================================== Scenario: r2plan diff shows correction diff when correction flag set Given r2plan-a mocked lifecycle service And r2plan-the apply service correction_diff returns formatted output for "CORR1" When r2plan-I invoke diff with plan "P1" and correction "CORR1" Then r2plan-the command should succeed And r2plan-the output should contain "Correction Diff" And r2plan-the output should contain "CORR1" # =================================================================== # execute_plan – auto-resolve with exactly one plan # =================================================================== Scenario: r2plan execute_plan auto-resolves single plan Given r2plan-a mocked lifecycle service And r2plan-the service lists exactly one complete strategize plan When r2plan-I invoke execute without plan_id Then r2plan-the command should succeed # =================================================================== # apply – auto-resolve with exactly one plan # =================================================================== Scenario: r2plan apply auto-resolves single plan Given r2plan-a mocked lifecycle service And r2plan-the service lists exactly one complete execute plan When r2plan-I invoke apply without plan_id Then r2plan-the command should succeed # =================================================================== # list_plans – projects > 2 truncation # =================================================================== Scenario: r2plan list truncates projects over 2 Given r2plan-a mocked lifecycle service And r2plan-the service lists a plan with 4 project links When r2plan-I invoke list Then r2plan-the command should succeed And r2plan-the output should contain "+2 more"