Skip to content

Commit

Permalink
Update examples and README
Browse files Browse the repository at this point in the history
  • Loading branch information
drewolson committed Jan 11, 2025
1 parent 6b2eea0 commit 750365d
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 103 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,36 @@

```gleam
import argv
import clip
import clip.{type Command}
import clip/help
import clip/opt
import clip/opt.{type Opt}
import gleam/io
import gleam/string
type Person {
Person(name: String, age: Int)
}
fn command() {
fn name_opt() -> Opt(String) {
opt.new("name") |> opt.help("Your name")
}
fn age_opt() -> Opt(Int) {
opt.new("age") |> opt.int |> opt.help("Your age")
}
fn command() -> Command(Person) {
clip.command({
use name <- clip.parameter
use age <- clip.parameter
Person(name, age)
})
|> clip.opt(opt.new("name") |> opt.help("Your name"))
|> clip.opt(opt.new("age") |> opt.int |> opt.help("Your age"))
|> clip.opt(name_opt())
|> clip.opt(age_opt())
}
pub fn main() {
pub fn main() -> Nil {
let result =
command()
|> clip.help(help.simple("person", "Create a person"))
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-opt-types/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "clip", version = "0.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.43.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "69EF22E78FDCA9097CBE7DF91C05B2A8B5436826D9F66680D879182C0860A747" },
{ name = "clip", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.52.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "50703862DF26453B277688FFCDBE9DD4AC45B3BD9742C0B370DB62BC1629A07D" },
]

[requirements]
Expand Down
4 changes: 2 additions & 2 deletions examples/default-values/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "clip", version = "0.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.43.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "69EF22E78FDCA9097CBE7DF91C05B2A8B5436826D9F66680D879182C0860A747" },
{ name = "clip", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.52.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "50703862DF26453B277688FFCDBE9DD4AC45B3BD9742C0B370DB62BC1629A07D" },
]

[requirements]
Expand Down
4 changes: 2 additions & 2 deletions examples/javascript/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "clip", version = "0.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.43.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "69EF22E78FDCA9097CBE7DF91C05B2A8B5436826D9F66680D879182C0860A747" },
{ name = "clip", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.52.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "50703862DF26453B277688FFCDBE9DD4AC45B3BD9742C0B370DB62BC1629A07D" },
]

[requirements]
Expand Down
4 changes: 2 additions & 2 deletions examples/many-opts/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "clip", version = "0.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.43.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "69EF22E78FDCA9097CBE7DF91C05B2A8B5436826D9F66680D879182C0860A747" },
{ name = "clip", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.52.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "50703862DF26453B277688FFCDBE9DD4AC45B3BD9742C0B370DB62BC1629A07D" },
]

[requirements]
Expand Down
4 changes: 0 additions & 4 deletions examples/parameter-syntax/.gitignore

This file was deleted.

20 changes: 0 additions & 20 deletions examples/parameter-syntax/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions examples/parameter-syntax/gleam.toml

This file was deleted.

13 changes: 0 additions & 13 deletions examples/parameter-syntax/manifest.toml

This file was deleted.

33 changes: 0 additions & 33 deletions examples/parameter-syntax/src/cli.gleam

This file was deleted.

4 changes: 2 additions & 2 deletions examples/simple/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "clip", version = "0.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.43.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "69EF22E78FDCA9097CBE7DF91C05B2A8B5436826D9F66680D879182C0860A747" },
{ name = "clip", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.52.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "50703862DF26453B277688FFCDBE9DD4AC45B3BD9742C0B370DB62BC1629A07D" },
]

[requirements]
Expand Down
20 changes: 14 additions & 6 deletions examples/simple/src/cli.gleam
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
import argv
import clip
import clip.{type Command}
import clip/help
import clip/opt
import clip/opt.{type Opt}
import gleam/io
import gleam/string

type Person {
Person(name: String, age: Int)
}

fn command() {
fn name_opt() -> Opt(String) {
opt.new("name") |> opt.help("Your name")
}

fn age_opt() -> Opt(Int) {
opt.new("age") |> opt.int |> opt.help("Your age")
}

fn command() -> Command(Person) {
clip.command({
use name <- clip.parameter
use age <- clip.parameter

Person(name, age)
})
|> clip.opt(opt.new("name") |> opt.help("Your name"))
|> clip.opt(opt.new("age") |> opt.int |> opt.help("Your age"))
|> clip.opt(name_opt())
|> clip.opt(age_opt())
}

pub fn main() {
pub fn main() -> Nil {
let result =
command()
|> clip.help(help.simple("person", "Create a person"))
Expand Down
4 changes: 2 additions & 2 deletions examples/subcommand-with-default/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "clip", version = "0.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.43.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "69EF22E78FDCA9097CBE7DF91C05B2A8B5436826D9F66680D879182C0860A747" },
{ name = "clip", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.52.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "50703862DF26453B277688FFCDBE9DD4AC45B3BD9742C0B370DB62BC1629A07D" },
]

[requirements]
Expand Down
4 changes: 2 additions & 2 deletions examples/subcommand/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "clip", version = "0.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.43.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "69EF22E78FDCA9097CBE7DF91C05B2A8B5436826D9F66680D879182C0860A747" },
{ name = "clip", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../.." },
{ name = "gleam_stdlib", version = "0.52.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "50703862DF26453B277688FFCDBE9DD4AC45B3BD9742C0B370DB62BC1629A07D" },
]

[requirements]
Expand Down

0 comments on commit 750365d

Please sign in to comment.