File tree Expand file tree Collapse file tree 13 files changed +92
-4
lines changed
lib/bashly/libraries/hooks Expand file tree Collapse file tree 13 files changed +92
-4
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ Each of these examples demonstrates one aspect or feature of bashly.
6262- [ yaml] ( yaml#readme ) - using the YAML reading functions
6363- [ completions] ( completions#readme ) - adding bash completion functionality
6464- [ validations] ( validations#readme ) - adding argument validation functions
65+ - [ hooks] ( hooks#readme ) - adding before/after hooks
6566
6667## Other Examples
6768
Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ $ bashly generate
1313$ bashly generate
1414```
1515
16- The ` bashly add colors ` command, simply created the [ src/lib/colors.sh ]
17- (src/lib/colors.sh) file, with useful color functions that will be
18- automatically included in the generated script.
16+ The ` bashly add colors ` command, simply created the
17+ [ src/lib/colors.sh ] ( src/lib/colors.sh ) file, with useful color functions that
18+ will be automatically included in the generated script.
1919
2020See the manually edited [ src/root_command.sh] ( src/root_command.sh ) for usage
2121examples.
Original file line number Diff line number Diff line change 1+ hooks
Original file line number Diff line number Diff line change 1+ # Before/After Hooks Example
2+
3+ This example demonstrates how to run common code before or after executing any
4+ command.
5+
6+ This example was generated with:
7+
8+ ``` bash
9+ $ bashly init
10+ # ... now edit src/bashly.yml to match the example ...
11+ $ bashly add hooks
12+ $ bashly generate
13+ ```
14+
15+ <!-- include: src/root_command.sh -->
16+
17+ -----
Original file line number Diff line number Diff line change 1+ # # after hook
2+ # #
3+ # # Any code here will be placed inside an `after_hook()` function and called
4+ # # after running any command.
5+ # #
6+ # # You can safely delete this file if you do not need it.
7+ echo " ==[ After Hook Called ]=="
Original file line number Diff line number Diff line change 1+ name : hooks
2+ help : Sample application that uses before/after hooks
3+ version : 0.1.0
4+
5+ flags :
6+ - long : --debug
7+ short : -d
8+ help : Enable debug mode
Original file line number Diff line number Diff line change 1+ # # before hook
2+ # #
3+ # # Any code here will be placed inside a `before_hook()` function and called
4+ # # before running any command (but after processing its arguments).
5+ # #
6+ # # You can safely delete this file if you do not need it.
7+ echo " ==[ Before Hook Called ]=="
8+ inspect_args
Original file line number Diff line number Diff line change 1+ # # Code here runs inside the initialize() function
2+ # # Use it for anything that you need to run before any other function, like
3+ # # setting environment variables:
4+ # # CONFIG_FILE=settings.ini
5+ # #
6+ # # Feel free to empty (but not delete) this file.
Original file line number Diff line number Diff line change 1+ echo " # this file is located in 'src/root_command.sh'"
2+ echo " # you can edit it freely and regenerate (it will not be overwritten)"
3+ inspect_args
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -x
4+
5+ bashly add hooks --force
6+ bashly generate
7+
8+ # ## Try Me ###
9+
10+ ./hooks
11+ ./hooks --debug
You can’t perform that action at this time.
0 commit comments