sam701/zig-cli

Support for arbitrary types

sam701 opened this issue · 0 comments

sam701 commented

This could be something like this

const Config = struct {
  host: []const u8,
  port: u32,
};
var config: Config = undefined;

var port_option = cli.Option{
    .long_name = "port",
    .help = "port",
    .value_ref = cli.valueRef(&config.port),
};

fn run_cmd(args: []const []const u8) anyerror!void {
  log.std.debug("addr: {}:{}\n", .{config.host, config.port});
}

Open questions:

  • how to check if a value was set.