Skip to content

Commit f3bc3bc

Browse files
authored
Merge pull request #7 from massix/feat/add-aliases-to-help
Print out existing aliases (if any) when printing the help page
2 parents 35265f6 + 0b6608d commit f3bc3bc

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
pkgs = import nixpkgs { inherit system; };
1111
inherit (pkgs) mkShell;
1212
gleamPackagesHash = "sha256-DIY9OA3ZigaVC2gxvwgCrF8rjNIraSy7mVqudp62x4M=";
13-
version = "1.3.0";
13+
version = "1.3.1";
1414
pname = "gleeter";
1515
src = ./.;
1616
gleam-helper = pkgs.callPackage ./nix/gleam-helper.nix { };

src/gleeter.gleam

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn print_comic(
131131
Ok(Nil)
132132
}
133133

134-
fn print_help() -> Result(Nil, Nil) {
134+
fn print_help(aliases: List(config.Alias)) -> Result(Nil, Nil) {
135135
let help_lines = [
136136
"usage: gleeter [command] [options]", "", "available commands:",
137137
" serve [port] [base_path]: start gleeter in server mode",
@@ -140,7 +140,18 @@ fn print_help() -> Result(Nil, Nil) {
140140
" random: print random comic",
141141
]
142142

143+
let aliases =
144+
list.map(aliases, fn(alias) {
145+
case alias {
146+
config.RandomAlias(_) -> " " <> alias.name <> ": print random comic"
147+
config.LatestAlias(_) -> " " <> alias.name <> ": print latest comic"
148+
config.IdAlias(_, id) ->
149+
" " <> alias.name <> ": print comic with id " <> int.to_string(id)
150+
}
151+
})
152+
143153
help_lines
154+
|> list.append(aliases)
144155
|> list.each(io.println)
145156
|> Ok
146157
}
@@ -163,7 +174,7 @@ pub fn main() -> Result(Nil, Nil) {
163174
print_comic(cache, configuration, ID(id))
164175
application_behavior.Serve(p, b) ->
165176
serve.serve(p, b, cache, configuration) |> Ok
166-
application_behavior.Help -> print_help()
177+
application_behavior.Help -> print_help(configuration.aliases)
167178
}
168179
let end = birl.now()
169180

src/version.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub const gleeter_version: String = "1.3.0"
1+
pub const gleeter_version: String = "1.3.1"
22

33
pub const github_url: String = "https://github.com/massix/gleeter"
44

0 commit comments

Comments
 (0)