Packages
glint
0.1.1
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-rc5
1.0.0-rc4
1.0.0-rc3
1.0.0-rc2
1.0.0-rc1
0.18.1
0.18.0
0.17.1
0.17.0
0.16.0
0.16.0-rc1
0.15.0
0.15.0-rc2
0.15.0-rc1
0.14.0
0.13.0
0.12.0
0.12.0-rc6
0.12.0-rc5
0.12.0-rc4
0.12.0-rc3
0.12.0-rc2
0.12.0-rc1
0.11.4
0.11.3
0.11.2
0.11.0
0.10.0
0.9.0
0.8.0
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.0
0.4.0
0.3.0
0.2.0
0.1.3
0.1.2
0.1.1
0.1.0
Gleam command-line argument parsing with flags and automated help text generation.
Current section
51 Versions
Jump to
Current section
51 Versions
Compare versions
5
files changed
+36
additions
-44
deletions
| @@ -1,5 +1,5 @@ | |
| 1 1 | name = "glint" |
| 2 | - version = "0.1.0" |
| 2 | + version = "0.1.1" |
| 3 3 | |
| 4 4 | # Fill out these fields if you intend to generate HTML documentation or publish |
| 5 5 | # your project to the Hex package manager. |
| @@ -1,6 +1,6 @@ | |
| 1 1 | {<<"name">>, <<"glint">>}. |
| 2 2 | {<<"app">>, <<"glint">>}. |
| 3 | - {<<"version">>, <<"0.1.0">>}. |
| 3 | + {<<"version">>, <<"0.1.1">>}. |
| 4 4 | {<<"description">>, <<"A simple command line runner for gleam">>}. |
| 5 5 | {<<"licenses">>, [<<"Apache-2.0">>]}. |
| 6 6 | {<<"build_tools">>, [<<"gleam">>]}. |
| @@ -8,15 +8,15 @@ | |
| 8 8 | {<<"Repository">>, <<"https://github.com/TanklesXL/glint">>} |
| 9 9 | ]}. |
| 10 10 | {<<"requirements">>, [ |
| 11 | - {<<"snag">>, [ |
| 12 | - {<<"app">>, <<"snag">>}, |
| 13 | - {<<"optional">>, false}, |
| 14 | - {<<"requirement">>, <<"~> 0.2">>} |
| 15 | - ]}, |
| 16 11 | {<<"gleam_stdlib">>, [ |
| 17 12 | {<<"app">>, <<"gleam_stdlib">>}, |
| 18 13 | {<<"optional">>, false}, |
| 19 14 | {<<"requirement">>, <<"~> 0.19">>} |
| 15 | + ]}, |
| 16 | + {<<"snag">>, [ |
| 17 | + {<<"app">>, <<"snag">>}, |
| 18 | + {<<"optional">>, false}, |
| 19 | + {<<"requirement">>, <<"~> 0.2">>} |
| 20 20 | ]} |
| 21 21 | ]}. |
| 22 22 | {<<"files">>, [ |
| @@ -1,5 +1,5 @@ | |
| 1 1 | {application, glint, [ |
| 2 | - {vsn, "0.1.0"}, |
| 2 | + {vsn, "0.1.1"}, |
| 3 3 | {applications, [gleam_stdlib, |
| 4 4 | gleeunit, |
| 5 5 | snag]}, |
| @@ -33,28 +33,22 @@ add_command(Root, Path, F, Flags) -> | |
| 33 33 | ); |
| 34 34 | |
| 35 35 | [X | Xs] -> |
| 36 | + Update_subcommand = fun(Node) -> case Node of |
| 37 | + none -> |
| 38 | + add_command( |
| 39 | + {command, none, gleam@map:new(), gleam@map:new()}, |
| 40 | + Xs, |
| 41 | + F, |
| 42 | + Flags |
| 43 | + ); |
| 44 | + |
| 45 | + {some, Node@1} -> |
| 46 | + add_command(Node@1, Xs, F, Flags) |
| 47 | + end end, |
| 36 48 | erlang:setelement( |
| 37 49 | 3, |
| 38 50 | Root, |
| 39 | - gleam@map:update( |
| 40 | - erlang:element(3, Root), |
| 41 | - X, |
| 42 | - fun(Node) -> case Node of |
| 43 | - none -> |
| 44 | - add_command( |
| 45 | - {command, |
| 46 | - none, |
| 47 | - gleam@map:new(), |
| 48 | - gleam@map:new()}, |
| 49 | - Xs, |
| 50 | - F, |
| 51 | - Flags |
| 52 | - ); |
| 53 | - |
| 54 | - {some, Node@1} -> |
| 55 | - add_command(Node@1, Xs, F, Flags) |
| 56 | - end end |
| 57 | - ) |
| 51 | + gleam@map:update(erlang:element(3, Root), X, Update_subcommand) |
| 58 52 | ) |
| 59 53 | end. |
| @@ -37,26 +37,24 @@ pub fn add_command( | |
| 37 37 | ) -> Command { |
| 38 38 | case path { |
| 39 39 | [] -> Command(..root, do: Some(f), flags: flag.build_map(flags)) |
| 40 | - [x, ..xs] -> |
| 40 | + [x, ..xs] -> { |
| 41 | + let update_subcommand = fn(node) { |
| 42 | + case node { |
| 43 | + None -> |
| 44 | + add_command( |
| 45 | + Command(do: None, subcommands: map.new(), flags: map.new()), |
| 46 | + xs, |
| 47 | + f, |
| 48 | + flags, |
| 49 | + ) |
| 50 | + Some(node) -> add_command(node, xs, f, flags) |
| 51 | + } |
| 52 | + } |
| 41 53 | Command( |
| 42 54 | ..root, |
| 43 | - subcommands: map.update( |
| 44 | - root.subcommands, |
| 45 | - x, |
| 46 | - fn(node) { |
| 47 | - case node { |
| 48 | - None -> |
| 49 | - add_command( |
| 50 | - Command(do: None, subcommands: map.new(), flags: map.new()), |
| 51 | - xs, |
| 52 | - f, |
| 53 | - flags, |
| 54 | - ) |
| 55 | - Some(node) -> add_command(node, xs, f, flags) |
| 56 | - } |
| 57 | - }, |
| 58 | - ), |
| 55 | + subcommands: map.update(root.subcommands, x, update_subcommand), |
| 59 56 | ) |
| 57 | + } |
| 60 58 | } |
| 61 59 | } |