Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
sam701 committed Nov 22, 2023
1 parent ca7493b commit 365050a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
```
Expand Down Expand Up @@ -84,4 +89,4 @@ OPTIONS:
```

## License
MIT
MIT
5 changes: 2 additions & 3 deletions examples/short.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 },
},
},
};
Expand Down

0 comments on commit 365050a

Please sign in to comment.