const config = @import("../config.zig"); const contracts = @import("../contracts.zig"); pub const CommandLineError = error{ OutOfMemory, MissingCommand, UnknownCommand, MissingConfigPath, MissingListenAddress, MissingAgentAddress, UnsupportedFlag, MissingWasmBackendValue, InvalidWasmBackend, ConflictingValidateMode, UnexpectedArgument, }; pub const Command = union(enum) { validate: ValidateCommand, run: RunCommand, run_distributed: DistributedRunCommand, agent: AgentCommand, help: HelpCommand, version, }; pub const HelpCommand = enum { general, validate, run, run_distributed, agent, }; pub const ValidateCommand = struct { config_path: []const u8, mode: contracts.ValidateMode, wasm_backend: ?config.WasmBackend = null, }; pub const RunCommand = struct { config_path: []const u8, wasm_backend: ?config.WasmBackend = null, }; pub const DistributedRunCommand = struct { config_path: []const u8, agent_addresses: []const []const u8, wasm_backend: ?config.WasmBackend = null, }; pub const AgentCommand = struct { listen_address: []const u8, }; pub fn commandLineErrorMessage(err: CommandLineError) []const u8 { return switch (err) { error.OutOfMemory => "out of memory", error.MissingCommand => "missing subcommand", error.UnknownCommand => "unknown subcommand", error.MissingConfigPath => "missing config path", error.MissingListenAddress => "missing value after --listen", error.MissingAgentAddress => "provide at least one --agent ", error.UnsupportedFlag => "unsupported flag", error.MissingWasmBackendValue => "missing value after --wasm-backend", error.InvalidWasmBackend => "invalid wasm backend, expected wamr or wasm3", error.ConflictingValidateMode => "choose at most one of --with-setup or --dry-run", error.UnexpectedArgument => "unexpected extra argument", }; }