Skip to content

Commit ac1df92

Browse files
authored
Merge pull request #684 from bashly-framework/add/extra-lib-dirs
Add `Settings.extra_lib_dirs` to allow loading files from multiple locations
2 parents efe753a + bf42d97 commit ac1df92

File tree

21 files changed

+236
-7
lines changed

21 files changed

+236
-7
lines changed

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Each of these examples demonstrates one aspect or feature of bashly.
5858
- [command-paths](command-paths#readme) - configuring nested paths for your source scripts
5959
- [command-function](command-function#readme) - configuring custom internal function names
6060
- [split-config](split-config#readme) - splitting your `bashly.yml` into several smaller files
61+
- [multiple-lib-dirs](multiple-lib-dirs#readme) - loading libraries from multiple locations
6162

6263
## Bashly library features
6364

examples/command-paths/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ commands:
7979
# The path to use for command files, relative to source_dir
8080
# When set to nil (~), command files will be placed directly under source_dir
8181
# When set to any other string, command files will be placed under this
82-
# directory, and each command will get its own subdirectory
82+
# directory, and each command will get its own sub-directory
8383

8484
# commands_dir: ~
8585
commands_dir: commands
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The path to use for command files, relative to source_dir
22
# When set to nil (~), command files will be placed directly under source_dir
33
# When set to any other string, command files will be placed under this
4-
# directory, and each command will get its own subdirectory
4+
# directory, and each command will get its own sub-directory
55

66
# commands_dir: ~
77
commands_dir: commands

examples/custom-includes/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ echo "After custom code"
5656
# Note that code here should be wrapped inside bash functions, and it is
5757
# recommended to have a separate file for each function.
5858
#
59-
# Subdirectories will also be scanned for *.sh, so you have no reason not
59+
# Sub-directories will also be scanned for *.sh, so you have no reason not
6060
# to organize your code neatly.
6161
#
6262
sample_function() {

examples/custom-includes/src/lib/sample_function.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Note that code here should be wrapped inside bash functions, and it is
66
# recommended to have a separate file for each function.
77
#
8-
# Subdirectories will also be scanned for *.sh, so you have no reason not
8+
# Sub-directories will also be scanned for *.sh, so you have no reason not
99
# to organize your code neatly.
1010
#
1111
sample_function() {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
download
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Multiple Lib Dirs
2+
3+
Demonstrates how to include more than one lib directories in the generated
4+
script.
5+
6+
This example was generated with:
7+
8+
```bash
9+
$ bashly init --minimal
10+
$ bashly add settings
11+
# ... now edit settings.yml to match the example ...
12+
$ bashly generate
13+
# ... now edit src/root_command.sh to match the example ...
14+
$ bashly generate
15+
```
16+
17+
<!-- include: settings.yml src/root_command.sh -->
18+
19+
-----
20+
21+
## `bashly.yml`
22+
23+
````yaml
24+
name: download
25+
help: Sample minimal application without commands
26+
version: 0.1.0
27+
28+
args:
29+
- name: source
30+
required: true
31+
help: URL to download from
32+
- name: target
33+
help: "Target filename (default: same as source)"
34+
35+
flags:
36+
- long: --force
37+
short: -f
38+
help: Overwrite existing files
39+
40+
examples:
41+
- download example.com
42+
- download example.com ./output -f
43+
````
44+
45+
## `settings.yml`
46+
47+
````yaml
48+
# An array or comma delimited string of additional directories to search for
49+
# bash functions. Any bash script found in any of these directories
50+
# (or sub-directories) will be merged into the final script.
51+
# Note that this is relative to the working directory.
52+
extra_lib_dirs: [common_lib, cloud_lib]
53+
54+
````
55+
56+
## `src/root_command.sh`
57+
58+
````bash
59+
# Calling library functions
60+
common_function
61+
cloud_function
62+
````
63+
64+
65+
## Output
66+
67+
### `$ ./download some_source`
68+
69+
````shell
70+
common_function called
71+
cloud_function called
72+
73+
74+
````
75+
76+
77+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cloud_function() {
2+
echo "cloud_function called"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
common_function() {
2+
echo "common_function called"
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# An array or comma delimited string of additional directories to search for
2+
# bash functions. Any bash script found in any of these directories
3+
# (or sub-directories) will be merged into the final script.
4+
# Note that this is relative to the working directory.
5+
extra_lib_dirs: [common_lib, cloud_lib]

0 commit comments

Comments
 (0)