diff --git a/src/cli_action.zig b/src/cli_action.zig index 095770b56..d852c243f 100644 --- a/src/cli_action.zig +++ b/src/cli_action.zig @@ -40,7 +40,7 @@ pub const Action = enum { pending = std.meta.stringToEnum(Action, arg[1..]) orelse return Error.InvalidAction; } - return null; + return pending; } /// Run the action. This returns the exit code to exit with. @@ -105,3 +105,38 @@ test "parse action version" { try testing.expect(action.? == .version); } } + +test "parse action plus" { + const testing = std.testing; + const alloc = testing.allocator; + + { + var iter = try std.process.ArgIteratorGeneral(.{}).init( + alloc, + "--a=42 --b --b-f=false +version", + ); + defer iter.deinit(); + const action = try Action.detectIter(&iter); + try testing.expect(action.? == .version); + } + + { + var iter = try std.process.ArgIteratorGeneral(.{}).init( + alloc, + "+version --a=42 --b --b-f=false", + ); + defer iter.deinit(); + const action = try Action.detectIter(&iter); + try testing.expect(action.? == .version); + } + + { + var iter = try std.process.ArgIteratorGeneral(.{}).init( + alloc, + "--c=84 --d +version --a=42 --b --b-f=false", + ); + defer iter.deinit(); + const action = try Action.detectIter(&iter); + try testing.expect(action.? == .version); + } +}