Skip to content

Commit

Permalink
adds help command
Browse files Browse the repository at this point in the history
  • Loading branch information
bwireman committed Jul 13, 2024
1 parent 4831382 commit 30bd488
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
otp: "27.0"
gleam: "1.3.1"
gleam: "1.3.2"
rebar: "3"

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gleam 1.3.1
gleam 1.3.2
erlang 27.0
nodejs 20.15.1
deno 1.44.4
25 changes: 21 additions & 4 deletions src/cactus.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,33 @@ pub fn main() -> Result(Nil, CactusErr) {

let cmd = get_cmd()
let res = case cmd {
"" | "init" -> {
write.init(hooks_dir, gleam_toml)
"help" | "--help" | "-h" -> {
util.print_info(
"
🌵 Cactus (version: 0.2.1)
---------------------------------------
A tool for managing git lifecycle hooks
with ✨ gleam! Pre commit, Pre push
and more!
Usage:
1. Configure your desired hooks in your project's `gleam.toml`
- More info: https://github.com/bwireman/cactus?tab=readme-ov-file#%EF%B8%8F-config
2. Run `gleam run -m cactus`
3. Celebrate! 🎉
",
)
Ok([])
}

arg -> {
"" | "init" -> write.init(hooks_dir, gleam_toml)

arg ->
case write.is_valid_hook_name(arg) {
True -> run.run(gleam_toml, arg)
False -> Error(CLIErr(arg))
}
}
}

case res {
Expand Down
5 changes: 5 additions & 0 deletions src/cactus/util.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,8 @@ pub fn print_warning(msg: String) {
shellout.style(msg <> "\n", with: shellout.color(["red"]), custom: [])
|> io.println
}

pub fn print_info(msg: String) {
shellout.style(msg <> "\n", with: shellout.color(["yellow"]), custom: [])
|> io.println
}

0 comments on commit 30bd488

Please sign in to comment.