From 365050a37207455ea5b5f9f0d4db2a0eb0387a6d Mon Sep 17 00:00:00 2001 From: Alexei Samokvalov Date: Wed, 22 Nov 2023 11:41:39 +0100 Subject: [PATCH] Update README --- README.md | 15 ++++++++++----- examples/short.zig | 5 ++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4ba8b7b..ff24697 100644 --- a/README.md +++ b/README.md @@ -44,16 +44,21 @@ var port = cli.Option{ .value_ref = cli.mkRef(&config.port), }; var app = &cli.App{ - .name = "short", - .options = &.{ &host, &port }, - .action = run_server, + .command = cli.Command{ + .name = "short", + .options = &.{ &host, &port }, + .description = cli.Description{ .one_line = "a short example" }, + .target = cli.CommandTarget{ + .action = cli.CommandAction{ .exec = run_server }, + }, + }, }; pub fn main() !void { return cli.run(app, allocator); } -fn run_server(_: []const []const u8) !void { +fn run_server() !void { std.log.debug("server is listening on {s}:{}", .{ config.host, config.port }); } ``` @@ -84,4 +89,4 @@ OPTIONS: ``` ## License -MIT \ No newline at end of file +MIT diff --git a/examples/short.zig b/examples/short.zig index dfa51b1..3a393ce 100644 --- a/examples/short.zig +++ b/examples/short.zig @@ -8,6 +8,7 @@ var config = struct { host: []const u8 = "localhost", port: u16 = undefined, }{}; + var host = cli.Option{ .long_name = "host", .help = "host to listen on", @@ -25,9 +26,7 @@ var app = &cli.App{ .options = &.{ &host, &port }, .description = cli.Description{ .one_line = "a short example" }, .target = cli.CommandTarget{ - .action = cli.CommandAction{ - .exec = run_server, - }, + .action = cli.CommandAction{ .exec = run_server }, }, }, };