-
Notifications
You must be signed in to change notification settings - Fork 2
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 #1 from hattan/hook_support
Hook support
- Loading branch information
Showing
4 changed files
with
102 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ######################################################### | ||
# Navigate to the examples folder and invoke this file. | ||
# cd examples | ||
# ./simple_example.sh -m hello -d | ||
# ######################################################### | ||
|
||
# load shArg | ||
source ../scripts/shArg.sh | ||
|
||
declare MESSAGE | ||
|
||
# Declare a hook method to fire when the message argument is found | ||
# Hook methods allow you to run a piece of code for additional behaviors when an argument is bound | ||
messageHook() { | ||
local message=$1 | ||
|
||
echo "message hooked invoked with $message" | ||
echo "Global variable is still available $MESSAGE" | ||
|
||
} | ||
|
||
# register arguments | ||
shArgs.arg "MESSAGE" -m --message PARAMETER true messageHook | ||
|
||
# parse inputs | ||
shArgs.parse $@ | ||
|
||
|
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