Packages
glint
0.12.0
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
8
files changed
+74
additions
-76
deletions
| @@ -31,7 +31,7 @@ gleam add glint | |
| 31 31 | |
| 32 32 | ### Mini Example |
| 33 33 | |
| 34 | - You can import `glint` as a dependency and use it to build simple command-line applications like the following simplified version of the [the hello world example](./examples/hello/README.md) |
| 34 | + You can import `glint` as a dependency and use it to build simple command-line applications like the following simplified version of the [the hello world example](https://github.com/TanklesXL/glint/tree/main/examples/hello/README.md) |
| 35 35 | |
| 36 36 | ```gleam |
| 37 37 | // stdlib imports |
| @@ -1,5 +1,5 @@ | |
| 1 1 | name = "glint" |
| 2 | - version = "0.12.0-rc6" |
| 2 | + version = "0.12.0" |
| 3 3 | |
| 4 4 | # Fill out these fields if you intend to generate HTML documentation or publishname = "glint" |
| 5 5 | # your project to the Hex package manager. |
| @@ -1,6 +1,6 @@ | |
| 1 1 | {<<"name">>, <<"glint">>}. |
| 2 2 | {<<"app">>, <<"glint">>}. |
| 3 | - {<<"version">>, <<"0.12.0-rc6">>}. |
| 3 | + {<<"version">>, <<"0.12.0">>}. |
| 4 4 | {<<"description">>, <<"Gleam command line argument parsing with basic flag support.">>}. |
| 5 5 | {<<"licenses">>, [<<"Apache-2.0">>]}. |
| 6 6 | {<<"build_tools">>, [<<"gleam">>]}. |
| @@ -10,25 +10,25 @@ | |
| 10 10 | {<<"Repository">>, <<"https://github.com/TanklesXL/glint">>} |
| 11 11 | ]}. |
| 12 12 | {<<"requirements">>, [ |
| 13 | - {<<"gleam_stdlib">>, [ |
| 14 | - {<<"app">>, <<"gleam_stdlib">>}, |
| 13 | + {<<"snag">>, [ |
| 14 | + {<<"app">>, <<"snag">>}, |
| 15 15 | {<<"optional">>, false}, |
| 16 | - {<<"requirement">>, <<"~> 0.19">>} |
| 16 | + {<<"requirement">>, <<"~> 0.2">>} |
| 17 17 | ]}, |
| 18 18 | {<<"gleam_community_ansi">>, [ |
| 19 19 | {<<"app">>, <<"gleam_community_ansi">>}, |
| 20 20 | {<<"optional">>, false}, |
| 21 21 | {<<"requirement">>, <<"~> 1.0">>} |
| 22 22 | ]}, |
| 23 | - {<<"snag">>, [ |
| 24 | - {<<"app">>, <<"snag">>}, |
| 25 | - {<<"optional">>, false}, |
| 26 | - {<<"requirement">>, <<"~> 0.2">>} |
| 27 | - ]}, |
| 28 23 | {<<"gleam_community_colour">>, [ |
| 29 24 | {<<"app">>, <<"gleam_community_colour">>}, |
| 30 25 | {<<"optional">>, false}, |
| 31 26 | {<<"requirement">>, <<"~> 1.0">>} |
| 27 | + ]}, |
| 28 | + {<<"gleam_stdlib">>, [ |
| 29 | + {<<"app">>, <<"gleam_stdlib">>}, |
| 30 | + {<<"optional">>, false}, |
| 31 | + {<<"requirement">>, <<"~> 0.19">>} |
| 32 32 | ]} |
| 33 33 | ]}. |
| 34 34 | {<<"files">>, [ |
| @@ -1,5 +1,5 @@ | |
| 1 1 | {application, glint, [ |
| 2 | - {vsn, "0.12.0-rc6"}, |
| 2 | + {vsn, "0.12.0"}, |
| 3 3 | {applications, [gleam_community_ansi, |
| 4 4 | gleam_community_colour, |
| 5 5 | gleam_stdlib, |
| @@ -13,13 +13,13 @@ | |
| 13 13 | gleam_community@colour:colour(), |
| 14 14 | gleam_community@colour:colour()}. |
| 15 15 | |
| 16 | - -opaque glint(GFT) :: {glint, |
| 16 | + -opaque glint(GGF) :: {glint, |
| 17 17 | config(), |
| 18 | - command_node(GFT), |
| 18 | + command_node(GGF), |
| 19 19 | gleam@map:map_(binary(), glint@flag:flag())}. |
| 20 20 | |
| 21 | - -opaque command(GFU) :: {command, |
| 22 | - fun((command_input()) -> GFU), |
| 21 | + -opaque command(GGG) :: {command, |
| 22 | + fun((command_input()) -> GGG), |
| 23 23 | gleam@map:map_(binary(), glint@flag:flag()), |
| 24 24 | binary()}. |
| 25 25 | |
| @@ -27,33 +27,33 @@ | |
| 27 27 | list(binary()), |
| 28 28 | gleam@map:map_(binary(), glint@flag:flag())}. |
| 29 29 | |
| 30 | - -type command_node(GFV) :: {command_node, |
| 31 | - gleam@option:option(command(GFV)), |
| 32 | - gleam@map:map_(binary(), command_node(GFV))}. |
| 30 | + -type command_node(GGH) :: {command_node, |
| 31 | + gleam@option:option(command(GGH)), |
| 32 | + gleam@map:map_(binary(), command_node(GGH))}. |
| 33 33 | |
| 34 | - -type out(GFW) :: {out, GFW} | {help, binary()}. |
| 34 | + -type out(GGI) :: {out, GGI} | {help, binary()}. |
| 35 35 | |
| 36 | - -type stub(GFX) :: {stub, |
| 36 | + -type stub(GGJ) :: {stub, |
| 37 37 | list(binary()), |
| 38 | - fun((command_input()) -> GFX), |
| 38 | + fun((command_input()) -> GGJ), |
| 39 39 | list({binary(), glint@flag:flag()}), |
| 40 40 | binary()}. |
| 41 41 | |
| 42 | - -spec with_config(glint(GGC), config()) -> glint(GGC). |
| 42 | + -spec with_config(glint(GGO), config()) -> glint(GGO). |
| 43 43 | with_config(Glint, Config) -> |
| 44 44 | erlang:setelement(2, Glint, Config). |
| 45 45 | |
| 46 | - -spec with_pretty_help(glint(GGF), pretty_help()) -> glint(GGF). |
| 46 | + -spec with_pretty_help(glint(GGR), pretty_help()) -> glint(GGR). |
| 47 47 | with_pretty_help(Glint, Pretty) -> |
| 48 48 | _pipe = erlang:setelement(2, erlang:element(2, Glint), {some, Pretty}), |
| 49 49 | with_config(Glint, _pipe). |
| 50 50 | |
| 51 | - -spec without_pretty_help(glint(GGI)) -> glint(GGI). |
| 51 | + -spec without_pretty_help(glint(GGU)) -> glint(GGU). |
| 52 52 | without_pretty_help(Glint) -> |
| 53 53 | _pipe = erlang:setelement(2, erlang:element(2, Glint), none), |
| 54 54 | with_config(Glint, _pipe). |
| 55 55 | |
| 56 | - -spec with_name(glint(GGL), binary()) -> glint(GGL). |
| 56 | + -spec with_name(glint(GGX), binary()) -> glint(GGX). |
| 57 57 | with_name(Glint, Name) -> |
| 58 58 | _pipe = erlang:setelement(3, erlang:element(2, Glint), {some, Name}), |
| 59 59 | with_config(Glint, _pipe). |
| @@ -66,7 +66,7 @@ empty_command() -> | |
| 66 66 | new() -> |
| 67 67 | {glint, {config, none, none}, empty_command(), gleam@map:new()}. |
| 68 68 | |
| 69 | - -spec do_add(command_node(GGV), list(binary()), command(GGV)) -> command_node(GGV). |
| 69 | + -spec do_add(command_node(GHH), list(binary()), command(GHH)) -> command_node(GHH). |
| 70 70 | do_add(Root, Path, Contents) -> |
| 71 71 | case Path of |
| 72 72 | [] -> |
| @@ -89,15 +89,15 @@ do_add(Root, Path, Contents) -> | |
| 89 89 | ) |
| 90 90 | end. |
| 91 91 | |
| 92 | - -spec command(fun((command_input()) -> GHE)) -> command(GHE). |
| 92 | + -spec command(fun((command_input()) -> GHQ)) -> command(GHQ). |
| 93 93 | command(Runner) -> |
| 94 94 | {command, Runner, gleam@map:new(), <<""/utf8>>}. |
| 95 95 | |
| 96 | - -spec description(command(GHH), binary()) -> command(GHH). |
| 96 | + -spec description(command(GHT), binary()) -> command(GHT). |
| 97 97 | description(Cmd, Description) -> |
| 98 98 | erlang:setelement(4, Cmd, Description). |
| 99 99 | |
| 100 | - -spec flag(command(GHK), binary(), glint@flag:flag_builder(any())) -> command(GHK). |
| 100 | + -spec flag(command(GHW), binary(), glint@flag:flag_builder(any())) -> command(GHW). |
| 101 101 | flag(Cmd, Key, Flag) -> |
| 102 102 | erlang:setelement( |
| 103 103 | 3, |
| @@ -105,11 +105,11 @@ flag(Cmd, Key, Flag) -> | |
| 105 105 | gleam@map:insert(erlang:element(3, Cmd), Key, glint@flag:build(Flag)) |
| 106 106 | ). |
| 107 107 | |
| 108 | - -spec flag_tuple(command(GHP), {binary(), glint@flag:flag_builder(any())}) -> command(GHP). |
| 108 | + -spec flag_tuple(command(GIB), {binary(), glint@flag:flag_builder(any())}) -> command(GIB). |
| 109 109 | flag_tuple(Cmd, Tup) -> |
| 110 110 | flag(Cmd, erlang:element(1, Tup), erlang:element(2, Tup)). |
| 111 111 | |
| 112 | - -spec flags(command(GHU), list({binary(), glint@flag:flag()})) -> command(GHU). |
| 112 | + -spec flags(command(GIG), list({binary(), glint@flag:flag()})) -> command(GIG). |
| 113 113 | flags(Cmd, Flags) -> |
| 114 114 | gleam@list:fold( |
| 115 115 | Flags, |
| @@ -124,7 +124,7 @@ flags(Cmd, Flags) -> | |
| 124 124 | end |
| 125 125 | ). |
| 126 126 | |
| 127 | - -spec global_flag(glint(GHY), binary(), glint@flag:flag_builder(any())) -> glint(GHY). |
| 127 | + -spec global_flag(glint(GIK), binary(), glint@flag:flag_builder(any())) -> glint(GIK). |
| 128 128 | global_flag(Glint, Key, Flag) -> |
| 129 129 | erlang:setelement( |
| 130 130 | 4, |
| @@ -132,11 +132,11 @@ global_flag(Glint, Key, Flag) -> | |
| 132 132 | gleam@map:insert(erlang:element(4, Glint), Key, glint@flag:build(Flag)) |
| 133 133 | ). |
| 134 134 | |
| 135 | - -spec global_flag_tuple(glint(GID), {binary(), glint@flag:flag_builder(any())}) -> glint(GID). |
| 135 | + -spec global_flag_tuple(glint(GIP), {binary(), glint@flag:flag_builder(any())}) -> glint(GIP). |
| 136 136 | global_flag_tuple(Glint, Tup) -> |
| 137 137 | global_flag(Glint, erlang:element(1, Tup), erlang:element(2, Tup)). |
| 138 138 | |
| 139 | - -spec global_flags(glint(GII), list({binary(), glint@flag:flag()})) -> glint(GII). |
| 139 | + -spec global_flags(glint(GIU), list({binary(), glint@flag:flag()})) -> glint(GIU). |
| 140 140 | global_flags(Glint, Flags) -> |
| 141 141 | erlang:setelement( |
| 142 142 | 4, |
| @@ -155,11 +155,11 @@ global_flags(Glint, Flags) -> | |
| 155 155 | ). |
| 156 156 | |
| 157 157 | -spec execute_root( |
| 158 | - command_node(GIW), |
| 158 | + command_node(GJI), |
| 159 159 | gleam@map:map_(binary(), glint@flag:flag()), |
| 160 160 | list(binary()), |
| 161 161 | list(binary()) |
| 162 | - ) -> {ok, out(GIW)} | {error, snag:snag()}. |
| 162 | + ) -> {ok, out(GJI)} | {error, snag:snag()}. |
| 163 163 | execute_root(Cmd, Global_flags, Args, Flag_inputs) -> |
| 164 164 | _pipe@3 = case erlang:element(2, Cmd) of |
| 165 165 | {some, Contents} -> |
| @@ -227,7 +227,7 @@ sanitize_path(Path) -> | |
| 227 227 | _pipe@1 = gleam@list:map(_pipe, fun gleam@string:trim/1), |
| 228 228 | gleam@list:filter(_pipe@1, fun is_not_empty/1). |
| 229 229 | |
| 230 | - -spec add(glint(GGQ), list(binary()), command(GGQ)) -> glint(GGQ). |
| 230 | + -spec add(glint(GHC), list(binary()), command(GHC)) -> glint(GHC). |
| 231 231 | add(Glint, Path, Contents) -> |
| 232 232 | erlang:setelement( |
| 233 233 | 3, |
| @@ -412,14 +412,14 @@ cmd_help(Path, Cmd, Config, Global_flags) -> | |
| 412 412 | gleam@string:join(_pipe@13, <<"\n\n"/utf8>>). |
| 413 413 | |
| 414 414 | -spec do_execute( |
| 415 | - command_node(GIQ), |
| 415 | + command_node(GJC), |
| 416 416 | config(), |
| 417 417 | gleam@map:map_(binary(), glint@flag:flag()), |
| 418 418 | list(binary()), |
| 419 419 | list(binary()), |
| 420 420 | boolean(), |
| 421 421 | list(binary()) |
| 422 | - ) -> {ok, out(GIQ)} | {error, snag:snag()}. |
| 422 | + ) -> {ok, out(GJC)} | {error, snag:snag()}. |
| 423 423 | do_execute(Cmd, Config, Global_flags, Args, Flags, Help, Command_path) -> |
| 424 424 | case Args of |
| 425 425 | [] when Help -> |
| @@ -455,7 +455,7 @@ do_execute(Cmd, Config, Global_flags, Args, Flags, Help, Command_path) -> | |
| 455 455 | end |
| 456 456 | end. |
| 457 457 | |
| 458 | - -spec execute(glint(GIM), list(binary())) -> {ok, out(GIM)} | |
| 458 | + -spec execute(glint(GIY), list(binary())) -> {ok, out(GIY)} | |
| 459 459 | {error, snag:snag()}. |
| 460 460 | execute(Glint, Args) -> |
| 461 461 | Help_flag = help_flag(), |
| @@ -480,7 +480,7 @@ execute(Glint, Args) -> | |
| 480 480 | [] |
| 481 481 | ). |
| 482 482 | |
| 483 | - -spec run_and_handle(glint(GJE), list(binary()), fun((GJE) -> any())) -> nil. |
| 483 | + -spec run_and_handle(glint(GJQ), list(binary()), fun((GJQ) -> any())) -> nil. |
| 484 484 | run_and_handle(Glint, Args, Handle) -> |
| 485 485 | case execute(Glint, Args) of |
| 486 486 | {error, Err} -> |
| @@ -500,7 +500,7 @@ run_and_handle(Glint, Args, Handle) -> | |
| 500 500 | run(Glint, Args) -> |
| 501 501 | run_and_handle(Glint, Args, gleam@function:constant(nil)). |
| 502 502 | |
| 503 | - -spec add_command_from_stub(glint(GJR), stub(GJR)) -> glint(GJR). |
| 503 | + -spec add_command_from_stub(glint(GKD), stub(GKD)) -> glint(GKD). |
| 504 504 | add_command_from_stub(Glint, Stub) -> |
| 505 505 | add( |
| 506 506 | Glint, |
Loading more files…