Skip to content
Draft

v2 #83

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: GH and Hex.pm Release

on:
push:
tags:
- v*.*.*
push:
tags:
- v*.*.*

jobs:
release:
uses: TanklesXL/gleam_actions/.github/workflows/release.yaml@main
secrets: inherit
with:
gleam_version: 1.9.1
erlang_version: 27
test_erlang: true
test_node: true
release:
uses: TanklesXL/gleam_actions/.github/workflows/release.yaml@main
secrets: inherit
with:
gleam_version: 1.12.0
erlang_version: 27
test_erlang: true
test_node: true
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Test

on:
push:
branches:
- main
pull_request:
workflow_call:
push:
branches:
- main
pull_request:
workflow_call:

jobs:
test:
uses: TanklesXL/gleam_actions/.github/workflows/test.yaml@main
with:
gleam_version: 1.9.1
test_node: true
test_erlang: true
test:
uses: TanklesXL/gleam_actions/.github/workflows/test.yaml@main
with:
gleam_version: 1.12.0
test_node: true
test_erlang: true
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ import argv
fn caps_flag() -> glint.Flag(Bool) {
// create a new boolean flag with key "caps"
// this flag will be called as --caps=true (or simply --caps as glint handles boolean flags in a bit of a special manner) from the command line
glint.bool_flag("caps")
glint.default("caps")
// set the flag default value to False
|> glint.flag_default(False)
|> glint.default(False)
// set the flag help text
|> glint.flag_help("Capitalize the hello message")
|> glint.param_help("Capitalize the hello message")
}

/// the glint command that will be executed
Expand Down Expand Up @@ -120,16 +120,16 @@ Glint flags are a type-safe way to provide options to your commands.

- Create a new flag with a typed flag constructor function:

- `glint.int_flag`: `glint.Flag(Int)`
- `glint.ints_flag`: `glint.Flag(List(Int))`
- `glint.float_flag`: `glint.Flag(Float)`
- `glint.floats_flag`: `glint.Flag(List(Floats))`
- `glint.string_flag`: `glint.Flag(String)`
- `glint.strings_flag`: `glint.Flag(List(String))`
- `glint.bool_flag`: `glint.Flag(Bool)`
- `glint.int`: `glint.Flag(Int)`
- `glint.ints`: `glint.Flag(List(Int))`
- `glint.float`: `glint.Flag(Float)`
- `glint.floats`: `glint.Flag(List(Floats))`
- `glint.string`: `glint.Flag(String)`
- `glint.strings`: `glint.Flag(List(String))`
- `glint.default`: `glint.Flag(Bool)`

- Set the flag description with `glint.flag_help`
- Set the flag default value with `glint.flag_default`, **note**: it is safe to use `let assert` when fetching values for flags with default values.
- Set the flag description with `glint.param_help`
- Set the flag default value with `glint.default`, **note**: it is safe to use `let assert` when fetching values for flags with default values.
- Add a flag to a command with `glint.flag`.
- Add a `constraint.Constraint(a)` to a `glint.Flag(a)` with `glint.flag_constraint`

Expand All @@ -148,8 +148,8 @@ import glint
import snag
// ...
// with pipes
glint.int_flag("my_int")
|> glint.flag_default(0)
glint.int("my_int")
|> glint.default(0)
|> glint.constraint(fn(i){
case i < 0 {
True -> snag.error("cannot be negative")
Expand All @@ -159,8 +159,8 @@ glint.int_flag("my_int")
// or
// with use
use i <- glint.flag_constraint(
glint.int_flag("my_int")
|> glint.flag_default(0)
glint.int("my_int")
|> glint.default(0)
)
case i < 0 {
True -> snag.error("cannot be negative")
Expand All @@ -181,8 +181,8 @@ import glint
import glint/constraint
import snag
// ...
glint.ints_flag("my_ints")
|> glint.flag_default([])
glint.ints("my_ints")
|> glint.default([])
|> glint.flag_constraint(
[1, 2, 3, 4]
|> constraint.one_of
Expand All @@ -208,7 +208,7 @@ Help text descriptions can be attached to all of glint's components:

- attach global help text with `glint.global_help`
- attach comand help text with `glint.command_help`
- attach flag help text with `glint.flag_help`
- attach flag help text with `glint.param_help`
- attach help text to a non-initialized command with `glint.path_help`

#### Help text formatting
Expand Down
39 changes: 23 additions & 16 deletions birdie_snapshots/cmd1_help.accepted
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
---
version: 1.1.5
version: 1.3.1
title: cmd1 help
file: ./test/glint_test.gleam
test_name: cmd1_help_test
---
Some awesome global help text!

Command: cmd1

This is cmd1

USAGE:
gleam run -m test cmd1 ( cmd3 | cmd4 ) [ ARGS ] [ --flag2=<INT>
--global=<STRING> --very-very-very-long-flag=<FLOAT_LIST> ]
gleam run -m test cmd1 ( cmd3 | cmd4 ) [ args.. ] [ flags ]

FLAGS:
--flag2=<INT> This is flag2
SUBCOMMANDS:
cmd3 This is cmd3

--global=<STRING> This is a global flag
cmd4 This is cmd4 which has a very very very very very very
very very long description

--help Print help information
ARGUMENTS:
args.. >= 0 args

--very-very-very-long-flag=<FLOAT_LIST> This is a very long flag with a
very very very very very very long
description
FLAGS:
--flag2=<int> This is flag2

SUBCOMMANDS:
cmd3 This is cmd3
--global=<string> This is a global
flag

cmd4 This is cmd4 which has a very very very very very very
very very long description
--help Print help
information

--version Print the app
version

--very-very-very-long-flag=<float list (comma-separated)> This is a very long
flag with a very
very very very very
very long
description
17 changes: 10 additions & 7 deletions birdie_snapshots/cmd2_help.accepted
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
version: 1.1.5
version: 1.2.6
title: cmd2 help
file: ./test/glint_test.gleam
test_name: help_test
test_name: cmd2_help_test
---
Some awesome global help text!

Command: cmd2

This is cmd2

USAGE:
gleam run -m test cmd2 <arg1> <arg2> [ --global=<STRING> ]
gleam run -m test cmd2 <arg1> <arg2> [ flags ]

ARGUMENTS:
arg1: float
arg2: string list (comma-separated)

FLAGS:
--global=<STRING> This is a global flag
--help Print help information
--global=<string> This is a global flag
--help Print help information
--version Print the app version
20 changes: 11 additions & 9 deletions birdie_snapshots/cmd3_help.accepted
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
---
version: 1.1.5
version: 1.2.6
title: cmd3 help
file: ./test/glint_test.gleam
test_name: help_test
test_name: cmd3_help_test
---
Some awesome global help text!

Command: cmd1 cmd3

This is cmd3

USAGE:
gleam run -m test cmd1 cmd3 <woo> [ 2 or more arguments ] [ --flag3=<BOOL>
--global=<STRING> ]
gleam run -m test cmd1 cmd3 <woo> [ args.. ] [ flags ]

ARGUMENTS:
args.. >= 2 args
woo: bool

FLAGS:
--flag3=<BOOL> This is flag3
--global=<STRING> This is a global flag
--help Print help information
--flag3=<bool> This is flag3
--global=<string> This is a global flag
--help Print help information
--version Print the app version
15 changes: 7 additions & 8 deletions birdie_snapshots/cmd4_help.accepted
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
---
version: 1.1.5
version: 1.2.6
title: cmd4 help
file: ./test/glint_test.gleam
test_name: help_test
test_name: cmd4_help_test
---
Some awesome global help text!

Command: cmd1 cmd4

This is cmd4 which has a very very very very very very very very long
description

USAGE:
gleam run -m test cmd1 cmd4 [ --flag4=<FLOAT> --global=<STRING> ]
gleam run -m test cmd1 cmd4 [ flags ]

FLAGS:
--flag4=<FLOAT> This is flag4
--global=<STRING> This is a global flag
--help Print help information
--flag4=<float> This is flag4
--global=<string> This is a global flag
--help Print help information
--version Print the app version
20 changes: 11 additions & 9 deletions birdie_snapshots/cmd6_help.accepted
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
---
version: 1.1.5
version: 1.3.1
title: cmd6 help
file: ./test/glint_test.gleam
test_name: help_test
test_name: cmd6_help_test
---
Some awesome global help text!

Command: cmd5 cmd6

This is cmd6

USAGE:
gleam run -m test cmd5 cmd6 ( cmd7 ) [ ARGS ] [ --global=<STRING> ]
gleam run -m test cmd5 cmd6 ( cmd7 ) [ args.. ] [ flags ]

SUBCOMMANDS:
cmd7 This is cmd7

ARGUMENTS:
args.. >= 0 args

FLAGS:
--global=<STRING> This is a global flag
--global=<string> This is a global flag
--help Print help information

SUBCOMMANDS:
cmd7 This is cmd7
--version Print the app version
18 changes: 10 additions & 8 deletions birdie_snapshots/cmd6_help_with_residual_args.accepted
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
---
version: 1.1.8
version: 1.3.1
title: cmd6 help with residual args
file: ./test/glint_test.gleam
test_name: call_help_with_residual_args_test
---
Some awesome global help text!

Command: cmd5 cmd6

This is cmd6

USAGE:
gleam run -m test cmd5 cmd6 ( cmd7 ) [ ARGS ] [ --global=<STRING> ]
gleam run -m test cmd5 cmd6 ( cmd7 ) [ args.. ] [ flags ]

SUBCOMMANDS:
cmd7 This is cmd7

ARGUMENTS:
args.. >= 0 args

FLAGS:
--global=<STRING> This is a global flag
--global=<string> This is a global flag
--help Print help information

SUBCOMMANDS:
cmd7 This is cmd7
--version Print the app version
11 changes: 6 additions & 5 deletions birdie_snapshots/cmd7_help.accepted
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
version: 1.1.5
version: 1.3.1
title: cmd7 help
file: ./test/glint_test.gleam
test_name: help_test
test_name: cmd7_help_test
---
Some awesome global help text!

Command: cmd5 cmd6 cmd7

This is cmd7

USAGE:
gleam run -m test cmd5 cmd6 cmd7 [ ARGS ]
gleam run -m test cmd5 cmd6 cmd7 [ args.. ]

ARGUMENTS:
args.. >= 0 args
Loading