Skip to content

Commit 26a61b6

Browse files
author
Ryan Miville
committed
more docs and minor tweaks
1 parent 49da5d5 commit 26a61b6

File tree

4 files changed

+333
-83
lines changed

4 files changed

+333
-83
lines changed

README.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ This program is in the [examples directory](https://github.com/ryanmiville/clad/
2424
```gleam
2525
import argv
2626
import clad
27-
import gleam/dynamic
2827
import gleam/io
2928
import gleam/list
3029
import gleam/string
@@ -41,14 +40,20 @@ fn greet(args: Args) {
4140
list.repeat(greeting, args.count) |> list.each(io.println)
4241
}
4342
43+
fn args_decoder() {
44+
use name <- clad.string(long_name: "name", short_name: "n")
45+
use count <- clad.int_with_default(
46+
long_name: "count",
47+
short_name: "c",
48+
default: 1,
49+
)
50+
use scream <- clad.bool(long_name: "scream", short_name: "s")
51+
clad.decoded(Args(name:, count:, scream:))
52+
}
53+
4454
pub fn main() {
4555
let args =
46-
dynamic.decode3(
47-
Args,
48-
clad.string(long_name: "name", short_name: "n"),
49-
clad.int(long_name: "count", short_name: "c") |> clad.with_default(1),
50-
clad.bool(long_name: "scream", short_name: "s"),
51-
)
56+
args_decoder()
5257
|> clad.decode(argv.load().arguments)
5358
5459
case args {

0 commit comments

Comments
 (0)