1
1
<div align =' center ' >
2
2
<img src =' logo.svg ' width =280 >
3
3
4
- Bashly - Bash CLI Framework and Generator
5
- ==================================================
4
+ # Bashly - Bash CLI Framework and Generator
6
5
7
6
Create beautiful bash scripts from simple YAML configuration
8
7
@@ -16,10 +15,28 @@ Create beautiful bash scripts from simple YAML configuration
16
15
17
16
</div >
18
17
18
+ ## Table of Contents
19
+
20
+ - [ Table of Contents] ( #table-of-contents )
21
+ - [ Installation] ( #installation )
22
+ - [ Prerequisites] ( #prerequisites )
23
+ - [ What is Bashly] ( #what-is-bashly )
24
+ - [ Usage] ( #usage )
25
+ - [ Using the input arguemnts in your code] ( #using-the-input-arguemnts-in-your-code )
26
+ - [ Examples] ( #examples )
27
+ - [ Sample configuraiton for a script without commands] ( #sample-configuraiton-for-a-script-without-commands )
28
+ - [ Sample configuraiton for a script with commands] ( #sample-configuraiton-for-a-script-with-commands )
29
+ - [ Configuration Reference] ( #configuration-reference )
30
+ - [ Command options] ( #command-options )
31
+ - [ Argument options] ( #argument-options )
32
+ - [ Flag options] ( #flag-options )
33
+ - [ Environment Variable options] ( #environment-variable-options )
34
+ - [ Real World Examples] ( #real-world-examples )
35
+ - [ Contributing / Support] ( #contributing--support )
36
+
19
37
---
20
38
21
- Installation
22
- --------------------------------------------------
39
+ ## Installation
23
40
24
41
``` shell
25
42
$ gem install bashly
@@ -31,15 +48,13 @@ or with Docker:
31
48
$ alias bashly=' docker run --rm -it --volume "$PWD:/app" dannyben/bashly'
32
49
```
33
50
34
- Prerequisites
35
- --------------------------------------------------
51
+ ## Prerequisites
36
52
37
53
The bash scripts generated by bashly require bash 4 or higher due to heavy
38
54
use of associative arrays.
39
55
40
56
41
- What is Bashly
42
- --------------------------------------------------
57
+ ## What is Bashly
43
58
44
59
Bashly is a command line application (written in Ruby) that lets you generate
45
60
feature-rich bash command line tools.
@@ -68,8 +83,7 @@ Bahsly is responsible for:
68
83
- ** YAML parsing** .
69
84
- and more.
70
85
71
- Usage
72
- --------------------------------------------------
86
+ ## Usage
73
87
74
88
In an empty directory, create a sample configuration file by running
75
89
@@ -99,9 +113,46 @@ Finally, edit the files in the `src` folder. Each of your script's commands
99
113
get their own file. Once you edit, run ` bashly generate ` again to merge the
100
114
content from your functions back into the script.
101
115
116
+ ### Using the input arguemnts in your code
117
+
118
+ In order to access the parsed arguments in any of your partial scripts, you
119
+ may simply access the ` $args ` associative array.
120
+
121
+ For example:
122
+
123
+ 1 . Generate a minimal configuration with ` bashly init --minimal `
124
+ 2 . Generate the bash script with ` bashly generate `
125
+ 3 . Run the script with ` ./download hello --force `
126
+
127
+ You will notice that all the arguments of the associative array are printed
128
+ on screen. This is done by the ` inspect_args ` function that was inserted into
129
+ the generated partial script ` src/root_command.sh ` .
130
+
131
+ You can now access these variables by modifying ` sec/root_command.sh ` like
132
+ this:
133
+
134
+
135
+ ``` bash
136
+ # src/root_command.sh
137
+ source_url=${args[source]}
138
+ force=${args[--force]}
139
+
140
+ if [[ $force ]]; then
141
+ echo " downloading $source_url with --force"
142
+ else
143
+ echo " downloading $source_url "
144
+ fi
145
+ ```
146
+
147
+ After editing the file, run ` bashly generate ` (or ` bashly g ` for short) and
148
+ run:
149
+
150
+ ```
151
+ $ ./download a --force
152
+ downloading a with --force
153
+ ```
102
154
103
- Examples
104
- --------------------------------------------------
155
+ ## Examples
105
156
106
157
The ` bashly.yml ` file can be set up to generate two types of scripts:
107
158
@@ -129,8 +180,7 @@ See the [examples](examples) folder for more examples.
129
180
130
181
131
182
132
- Configuration Reference
133
- --------------------------------------------------
183
+ ## Configuration Reference
134
184
135
185
The ` bashly.yml ` configuration file consists of these types:
136
186
@@ -210,16 +260,14 @@ set.
210
260
` required ` | Specify if this variable is required.
211
261
212
262
213
- Real World Examples
214
- --------------------------------------------------
263
+ ## Real World Examples
215
264
216
265
- [ Rush] [ rush ] - a Personal Package Manager
217
266
- [ Alf] [ alf ] - a generator for bash aliases and sub-aliases
218
267
- [ git-changelog] [ git-changelog ] - a change log generator
219
268
220
269
221
- Contributing / Support
222
- --------------------------------------------------
270
+ ## Contributing / Support
223
271
224
272
If you experience any issue, have a question or a suggestion, or if you wish
225
273
to contribute, feel free to [ open an issue] [ issues ] .
0 commit comments