bashly 0.4.0 → 0.4.1rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +66 -18
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/inspect_args.erb +7 -2
- data/lib/bashly/views/flag/case.erb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e31810f90eb5199f74dd9fd0dc0aedfb4bfd5dd4f38bc4e36473ab6c3e4f10d2
|
4
|
+
data.tar.gz: 5de458e2eea4ec796e44a67cddeabaf848ef069ec2d37ad7ddb1f3cc660bad27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72a03554e17b648efda96ac0208bd4ee8223680717933a71907994ca3a3db3ffd629ea3572fc27143babb6634a65ad2f0b83fdeaeea2ab01d0c4755ea630f674
|
7
|
+
data.tar.gz: eb955f344c428e92b82150b95256f3c9d90e3461353bb6b13cad68eeb17bf5e6220991590aa1d797b447ee5c92f414ef9b5042b13569a284595dac0cadd7babd
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
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].
|
data/lib/bashly/version.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# :command.inspect_args
|
2
2
|
inspect_args() {
|
3
|
-
|
4
|
-
|
3
|
+
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
4
|
+
if (( ${#args[@]} )); then
|
5
|
+
echo args:
|
6
|
+
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
|
7
|
+
else
|
8
|
+
echo args: none
|
9
|
+
fi
|
5
10
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bashly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -138,11 +138,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: 2.3.0
|
139
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
|
-
- - "
|
141
|
+
- - ">"
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
143
|
+
version: 1.3.1
|
144
144
|
requirements: []
|
145
|
-
rubygems_version: 3.
|
145
|
+
rubygems_version: 3.2.3
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Bash Command Line Tool Generator
|