╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ command.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
261 .command = switch (dispatch) { 262 .invalid => return dispatch, // if there was already an error, return it instead 263 .help => |cmd_kind_maybe| cmd_kind_maybe, 264 .cli => |command| command, 265 }, 266 .value = cmd_args.unused_args.keys()[0], 267 }, 268 }, 269 }; 270 } 271 return dispatch; 272 } 273 274 pub fn initIgnoreUnused(cmd_args: *CommandArgs) !CommandDispatch { 275 const show_help = cmd_args.contains("--help"); 276 277 if (cmd_args.command_kind) |command_kind| { 278 if (show_help) { 279 return .{ .help = command_kind }; 280 } else if (try Command.initMaybe(cmd_args)) |cmd| { 281 return .{ .cli = cmd }; 282 } else { 283 return .{ .help = command_kind }; 284 } 285 } else if (cmd_args.command_name) |command_name| { 286 return .{ .invalid = .{ .command = command_name } }; 287 } else if (show_help) { 288 return .{ .help = null }; 289 } else { 290 return .{ .help = null }; 291 } 292 } 293 }; 294