-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from ahoy-cli/add-command-aliases
feature: Add command aliases as requested in #110
- Loading branch information
Showing
5 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ahoyapi: v2 | ||
commands: | ||
hello: | ||
usage: Say hello | ||
cmd: echo "Hello, World!" | ||
aliases: ["hi", "greet", "ahoy"] | ||
|
||
ahoy-there: | ||
usage: Say "ahoy there!" | ||
cmd: echo "ahoy there!" | ||
aliases: ["ahoy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bats | ||
|
||
load 'test_helpers/bats-support/load' | ||
load 'test_helpers/bats-assert/load' | ||
|
||
@test "Command aliases work correctly" { | ||
run ./ahoy -f testdata/command-aliases.ahoy.yml hello | ||
[[ "$output" =~ "Hello, World!" ]] | ||
[ "$status" -eq 0 ] | ||
|
||
run ./ahoy -f testdata/command-aliases.ahoy.yml hi | ||
[[ "$output" =~ "Hello, World!" ]] | ||
[ "$status" -eq 0 ] | ||
|
||
run ./ahoy -f testdata/command-aliases.ahoy.yml greet | ||
[[ "$output" =~ "Hello, World!" ]] | ||
[ "$status" -eq 0 ] | ||
|
||
run ./ahoy -f testdata/command-aliases.ahoy.yml | ||
[[ "$output" =~ "hello, hi, greet" ]] | ||
[[ "$output" =~ "Aliases: hi, greet" ]] | ||
|
||
# Should exit with error as no command was supplied. | ||
[ "$status" -eq 1 ] | ||
} | ||
|
||
@test "Say ahoy there" { | ||
run ./ahoy -f testdata/command-aliases.ahoy.yml ahoy-there | ||
[[ "$output" =~ "ahoy there!" ]] | ||
[ "$status" -eq 0 ] | ||
|
||
run ./ahoy -f testdata/command-aliases.ahoy.yml ahoy | ||
[[ "$output" =~ "ahoy there!" ]] | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Multiple conflicting aliases means the last one loaded takes precedence" { | ||
run ./ahoy -f testdata/command-aliases.ahoy.yml ahoy | ||
[[ "$output" =~ "ahoy there!" ]] | ||
[ "$status" -eq 0 ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters