Add "edit" command

This commit is contained in:
The Magician 2023-12-08 17:57:00 +00:00
parent c0bd1e11fc
commit d2405b8b3b
3 changed files with 19 additions and 1 deletions

View File

@ -31,6 +31,15 @@ test_get_command_returns_new_for_substring() {
done done
} }
test_get_command_returns_edit_for_substring() {
expected="edit"
for arg in e ed edi edit; do
result="$(get_command "$ZKCOMMANDS" "$arg")"
assert_equals "$expected" "$result"
done
}
test_get_command_does_not_return_match_unless_at_start_of_command_string() { test_get_command_does_not_return_match_unless_at_start_of_command_string() {
commands="delete" commands="delete"
expected="" expected=""

View File

@ -34,3 +34,12 @@ test_main_calls_new_when_new_command_passed() {
assert_equals "$expected" "$result" assert_equals "$expected" "$result"
} }
test_main_calls_edit_when_edit_command_passed() {
expected="_zk_edit"
fake get_command 'echo edit'
fake _zk_edit "echo $expected"
result="$(main)"
assert_equals "$expected" "$result"
}

2
zk
View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
ZKDIR="$HOME/.local/share/zk/" ZKDIR="$HOME/.local/share/zk/"
ZKCOMMANDS='list search new' ZKCOMMANDS='list search new edit'
get_command() { get_command() {
commands="$1" commands="$1"