-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* greatly speed up sash-parse * split out sash-trap from sash-err-stack * add tests * add sash-parse level CLI.
- Loading branch information
Cynthia Coan
committed
Aug 3, 2019
1 parent
9314441
commit b607d6e
Showing
29 changed files
with
596 additions
and
201 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
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,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "$SASH_DIR/subcommands/sash-add.sh" | ||
source "$SASH_DIR/subcommands/sash-package.sh" | ||
source "$SASH_DIR/subcommands/sash-show.sh" | ||
|
||
SASH_ARGS=("h|help") | ||
|
||
sash() { | ||
__sash_parse_args "$*" "${SASH_ARGS[@]}" || { | ||
printf 'Failure to parse arguments!\nRemember argument flags should not be between sash and subcommand.' | ||
return 10 | ||
} | ||
|
||
local split_stdin=($(__sash_split_str "${__sash_parse_results[__STDIN]}" " ")) | ||
|
||
if [[ "${split_stdin[0]}" == "add" ]]; then | ||
sash:add | ||
return $? | ||
fi | ||
if [[ "${split_stdin[0]}" == "show" ]]; then | ||
sash:show "${split_stdin[@]:1}" | ||
return $? | ||
fi | ||
if [[ "${split_stdin[0]}" == "package" ]]; then | ||
sash:package "${split_stdin[@]:1}" | ||
return $? | ||
fi | ||
|
||
echo " | ||
Welcome to S.A.S.H.! | ||
S.A.S.H. offers the following subcommands: | ||
* \`add\` - add something to your bashrc | ||
(and automatically source it). | ||
* \`show (category) (sub-category)\` - show the contents of a paritcular | ||
subcategory. | ||
* \`package\` - package up a particular category | ||
or subcategory for distribution to | ||
others. | ||
NOTE: anything between: \`()\` above denotes optional arguments. | ||
If you don't provide them, and they're needed, you will be asked inline. | ||
" | ||
return 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
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
9 changes: 9 additions & 0 deletions
9
sash-libs/sash-err-stack/tests/test-cases/test-can-be-sourced-in-err-mode.sh
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,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
source "$SCRIPT_DIR/../../sash-err-stack.sh" | ||
|
||
false | ||
echo "hey" |
19 changes: 19 additions & 0 deletions
19
sash-libs/sash-err-stack/tests/test-cases/test-err-mode-mixup.sh
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,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
source "$SCRIPT_DIR/../../sash-err-stack.sh" | ||
|
||
function messWithGlobalErrorMode() { | ||
set +e | ||
false | ||
echo "hey" | ||
} | ||
|
||
function guard() { | ||
__sash_guard_errors | ||
messWithGlobalErrorMode | ||
false | ||
echo "hello world" | ||
} | ||
|
||
guard |
5 changes: 5 additions & 0 deletions
5
sash-libs/sash-err-stack/tests/test-cases/test-source-multiple-times.sh
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,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
source "$SCRIPT_DIR/../../sash-err-stack.sh" | ||
source "$SCRIPT_DIR/../../sash-err-stack.sh" |
Oops, something went wrong.