Skip to content

Commit

Permalink
more docs and minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmiville committed Sep 5, 2024
1 parent 49da5d5 commit 7cc47ce
Show file tree
Hide file tree
Showing 5 changed files with 334 additions and 84 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ This program is in the [examples directory](https://github.com/ryanmiville/clad/
```gleam
import argv
import clad
import gleam/dynamic
import gleam/io
import gleam/list
import gleam/string
Expand All @@ -41,14 +40,20 @@ fn greet(args: Args) {
list.repeat(greeting, args.count) |> list.each(io.println)
}
fn args_decoder() {
use name <- clad.string(long_name: "name", short_name: "n")
use count <- clad.int_with_default(
long_name: "count",
short_name: "c",
default: 1,
)
use scream <- clad.bool(long_name: "scream", short_name: "s")
clad.decoded(Args(name:, count:, scream:))
}
pub fn main() {
let args =
dynamic.decode3(
Args,
clad.string(long_name: "name", short_name: "n"),
clad.int(long_name: "count", short_name: "c") |> clad.with_default(1),
clad.bool(long_name: "scream", short_name: "s"),
)
args_decoder()
|> clad.decode(argv.load().arguments)
case args {
Expand Down
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "clad"
version = "0.1.0"
version = "0.1.1"

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
Expand Down
Loading

0 comments on commit 7cc47ce

Please sign in to comment.