Skip to content

Commit 0487efe

Browse files
authored
Merge pull request #35 from DannyBen/next
Next: Variable
2 parents fe2e22e + 4f4d959 commit 0487efe

File tree

8 files changed

+106
-39
lines changed

8 files changed

+106
-39
lines changed

Gemfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ GEM
2424
http-cookie (~> 1.0)
2525
http-form_data (~> 2.2)
2626
llhttp-ffi (~> 0.5.0)
27-
http-cookie (1.0.6)
27+
http-cookie (1.0.7)
2828
domain_name (~> 0.5)
2929
http-form_data (2.3.0)
3030
httpme (0.2.2)
@@ -40,16 +40,16 @@ GEM
4040
colsole (>= 0.8.1, < 2)
4141
docopt_ng (~> 0.7, >= 0.7.1)
4242
module_methods (0.1.0)
43-
mustermann (3.0.0)
43+
mustermann (3.0.3)
4444
ruby2_keywords (~> 0.0.1)
4545
nio4r (2.7.3)
46-
nokogiri (1.16.6-x86_64-linux)
46+
nokogiri (1.16.7-x86_64-linux)
4747
racc (~> 1.4)
48-
public_suffix (6.0.0)
49-
puma (6.4.2)
48+
public_suffix (6.0.1)
49+
puma (6.4.3)
5050
nio4r (~> 2.0)
51-
racc (1.8.0)
52-
rack (3.1.6)
51+
racc (1.8.1)
52+
rack (3.1.8)
5353
rack-contrib (2.5.0)
5454
rack (< 4)
5555
rack-protection (4.0.0)
@@ -84,4 +84,4 @@ DEPENDENCIES
8484
sla
8585

8686
BUNDLED WITH
87-
2.5.14
87+
2.5.22

retype.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ editor:
1313
branding:
1414
logo: assets/logo.svg
1515
logoDark: assets/logo-dark.svg
16-
label: v1.2.3
16+
label: v1.2.4
1717

1818
meta:
1919
title: " | Bashly - Bash Command Line Framework"

src/advanced/bash-completion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ By running `bashly generate --upgrade`, your completions function
3939

4040
## Custom command completions
4141

42-
In addition to the automatic suggestion of sub-commands and flags, you can
42+
In addition to the automatic suggestion of subcommands and flags, you can
4343
instruct bashly to also suggest files, directories, users, git branches and
4444
more. To do this, add another option in your `bashly.yml` on the command you
4545
wish to alter:

src/configuration/command.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ order: 100
88
The `command` object serves two purposes, it:
99

1010
1. Defines the root CLI application (command).
11-
2. Defines any nested sub-commands, if any.
11+
2. Defines any nested subcommands, if any.
1212

1313
==- :icon-code-review: Show Me How
1414
```yaml bashly.yml
@@ -52,7 +52,7 @@ commands:
5252
===
5353
5454
Unless otherwise specified, these definitions can be used for both the root
55-
command and sub-commands (under the `commands` definition).
55+
command and subcommands (under the `commands` definition).
5656

5757
!!! Note
5858
Most properties are optional, unless specified otherwise.
@@ -66,17 +66,13 @@ Most properties are optional, unless specified otherwise.
6666
[!badge String]
6767
[!badge variant="danger" text="Required"]
6868

69-
The name of the script or sub-command.
69+
The name of the script or subcommand.
7070

7171

7272
### alias
7373

7474
[!badge String / Array of Strings]
75-
[!badge variant="warning" text="Sub-Commands Only"]
76-
77-
!!! Note
78-
This command used to be called `short` in bashly < 0.8.0
79-
!!!
75+
[!badge variant="warning" text="Subcommands Only"]
8076

8177
One or more additional optional names for this command. This can be used to
8278
create a shortcut for a command, or provide alternative names for it.
@@ -124,9 +120,9 @@ Specify the array of positional arguments this script needs.
124120
Specify the array of option flags this script needs.
125121

126122
!!! Note
127-
Flags that are defined in a command that has sub-commands, are considered
128-
"global flags", and will be available to all sub-commands, in addition to any
129-
flag defined in any of the sub-commands themselves.
123+
Flags that are defined in a command that has subcommands, are considered
124+
"global flags", and will be available to all subcommands, in addition to any
125+
flag defined in any of the subcommands themselves.
130126

131127
The [docker-like example](https://github.com/DannyBen/bashly/tree/master/examples/docker-like#readme)
132128
demonstrates this feature.
@@ -145,7 +141,7 @@ Specify the array of commands. Each command will have its own args and flags.
145141
Using `commands` on a given command implies that this command does not have flags or args.
146142
!!!
147143

148-
[!button variant="primary" icon="code-review" text="Commands Example"](https://github.com/DannyBen/bashly/tree/master/examples/commands#readme) [!button variant="primary" icon="code-review" text="Sub-Commands Example"](https://github.com/DannyBen/bashly/tree/master/examples/commands-nested#readme)
144+
[!button variant="primary" icon="code-review" text="Commands Example"](https://github.com/DannyBen/bashly/tree/master/examples/commands#readme) [!button variant="primary" icon="code-review" text="Subcommands Example"](https://github.com/DannyBen/bashly/tree/master/examples/commands-nested#readme)
149145

150146

151147

@@ -164,7 +160,7 @@ The string to display when using `--version`.
164160
### default
165161

166162
[!badge Boolean / String]
167-
[!badge variant="warning" text="Sub-Commands Only"]
163+
[!badge variant="warning" text="Subcommands Only"]
168164

169165
- Setting this to `true` on any command, will cause any **unrecognized**
170166
command line to be passed to this command.
@@ -204,7 +200,7 @@ Add a custom message that will be displayed at the end of the `--help` text.
204200
### group
205201

206202
[!badge String]
207-
[!badge variant="warning" text="Sub-Commands Only"]
203+
[!badge variant="warning" text="Subcommands Only"]
208204

209205
In case you have many commands, use this option to specify a caption to display
210206
before this command.
@@ -213,7 +209,13 @@ This option is purely for display purposes.
213209

214210
[!button variant="primary" icon="code-review" text="Command Groups Example"](https://github.com/DannyBen/bashly/tree/master/examples/command-groups#readme)
215211

212+
### variables
213+
214+
[!badge Array of Variables]
215+
216+
Specify an array of variables that can be accessed globally in your script, or subcommands.
216217

218+
[!ref](variable.md)
217219

218220
## Advanced Options
219221

@@ -261,17 +263,17 @@ script.
261263
### expose
262264

263265
[!badge Boolean / String]
264-
[!badge variant="warning" text="Sub-Commands Only"]
266+
[!badge variant="warning" text="Subcommands Only"]
265267

266-
Setting this to `true` or `always` on any command that has sub-commands, will
267-
show its sub-commands in the help or usage text of the parent command.
268+
Setting this to `true` or `always` on any command that has subcommands, will
269+
show its subcommands in the help or usage text of the parent command.
268270

269-
- Set to `true` to show the sub-commands only when the parent command is
271+
- Set to `true` to show the subcommands only when the parent command is
270272
executed with `--help`.
271-
- Set to `always` to show the sub-commands also when the parent command is
273+
- Set to `always` to show the subcommands also when the parent command is
272274
executed without any arguments.
273275

274-
You can use `expose` with the [`group`](#group) option, to show sub-commands
276+
You can use `expose` with the [`group`](#group) option, to show subcommands
275277
in a logical, visual grouping.
276278

277279
[!button variant="primary" icon="code-review" text="Commands Expose Example"](https://github.com/DannyBen/bashly/tree/master/examples/commands-expose#readme)
@@ -341,7 +343,7 @@ as a "last resort" mechanism to help in solving more complex scenarios.
341343
### private
342344

343345
[!badge Boolean]
344-
[!badge variant="warning" text="Sub-Commands Only"]
346+
[!badge variant="warning" text="Subcommands Only"]
345347

346348
Setting this to `true` on any command, will hide it from the command list.
347349

src/configuration/variable.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
icon: dot
3+
order: 50
4+
---
5+
6+
# Variable
7+
8+
This option allows you to define bash variables that will be accessible in your
9+
script and its subcommands. While it's possible to define variables directly
10+
within your bash script, this feature provides a structured alternative by
11+
enabling you to centralize variable definitions in the YAML configuration file.
12+
13+
This approach helps to organize your variables separately from the main script
14+
logic, improving readability and maintainability. It is important to note that
15+
using this option is optional, and you can continue to define variables
16+
directly in your bash script if preferred.
17+
18+
==- :icon-code-review: Show Me How
19+
```yaml bashly.yml
20+
variables:
21+
# Simple value
22+
- name: output_folder
23+
value: output
24+
25+
# Array
26+
- name: download_sources
27+
value:
28+
- youtube
29+
- instagram
30+
31+
# Associative array
32+
- name: zip_options
33+
value:
34+
pattern: "*.json"
35+
compression_level: fast
36+
```
37+
===
38+
39+
!!!success Tip
40+
Variables defined in the root command are available globally, while those
41+
defined in subcommands are only accessible within those specific commands.
42+
!!!
43+
44+
[!button variant="primary" icon="code-review" text="Variables Example"](https://github.com/DannyBen/bashly/tree/master/examples/variables#readme)
45+
46+
## Basic Options
47+
48+
### name
49+
50+
[!badge String]
51+
[!badge variant="danger" text="Required"]
52+
53+
The name of the variable.
54+
55+
### value
56+
57+
[!badge Any Type]
58+
59+
The variable's value can be a simple type such as a string, number, or boolean,
60+
or a one-level complex structure like an array or associative array (hash).

src/examples.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ All examples are listed below for convenience.
1616
## Basic use
1717

1818
- [minimal](https://github.com/DannyBen/bashly/tree/master/examples/minimal#readme) - the most basic "hello world" example
19-
- [commands](https://github.com/DannyBen/bashly/tree/master/examples/commands#readme) - a script with sub-commands
20-
- [commands-nested](https://github.com/DannyBen/bashly/tree/master/examples/commands-nested#readme) - a script with nested sub-commands
19+
- [commands](https://github.com/DannyBen/bashly/tree/master/examples/commands#readme) - a script with subcommands
20+
- [commands-nested](https://github.com/DannyBen/bashly/tree/master/examples/commands-nested#readme) - a script with nested subcommands
2121

2222
## Basic features
2323

@@ -28,6 +28,7 @@ All examples are listed below for convenience.
2828
- [dependencies](https://github.com/DannyBen/bashly/tree/master/examples/dependencies#readme) - halting script execution unless certain dependencies are installed
2929
- [dependencies-alt](https://github.com/DannyBen/bashly/tree/master/examples/dependencies-alt#readme) - halting script execution unless one of the required dependencies is installed
3030
- [environment-variables](https://github.com/DannyBen/bashly/tree/master/examples/environment-variables#readme) - halting script execution unless certain environment variables are set
31+
- [variables](https://github.com/DannyBen/bashly/tree/master/examples/variables#readme) - defining bash variables
3132
- [default-values](https://github.com/DannyBen/bashly/tree/master/examples/default-values#readme) - arguments and flags with default values
3233
- [minus-v](https://github.com/DannyBen/bashly/tree/master/examples/minus-v#readme) - using `-v` and `-h` in your script
3334
- [multiline](https://github.com/DannyBen/bashly/tree/master/examples/multiline#readme) - help messages with multiple lines
@@ -49,14 +50,14 @@ All examples are listed below for convenience.
4950
- [private-reveal](https://github.com/DannyBen/bashly/tree/master/examples/private-reveal#readme) - allowing users to reveal private commands, flags or environment variables
5051
- [stdin](https://github.com/DannyBen/bashly/tree/master/examples/stdin#readme) - reading input from stdin
5152
- [filters](https://github.com/DannyBen/bashly/tree/master/examples/filters#readme) - preventing commands from running unless custom conditions are met
52-
- [commands-expose](https://github.com/DannyBen/bashly/tree/master/examples/commands-expose#readme) - showing sub-commands in the parent's help
53+
- [commands-expose](https://github.com/DannyBen/bashly/tree/master/examples/commands-expose#readme) - showing subcommands in the parent's help
5354
- [key-value-pairs](https://github.com/DannyBen/bashly/tree/master/examples/key-value-pairs#readme) - parsing key=value arguments and flags
5455
- [command-examples-on-error](https://github.com/DannyBen/bashly/tree/master/examples/command-examples-on-error#readme) - showing examples on error
5556

5657
## Customization
5758

5859
- [colors-usage](https://github.com/DannyBen/bashly/tree/master/examples/colors-usage#readme) - adding colors to the usage text
59-
- [command-groups](https://github.com/DannyBen/bashly/tree/master/examples/command-groups#readme) - grouping sub-commands in logical sections
60+
- [command-groups](https://github.com/DannyBen/bashly/tree/master/examples/command-groups#readme) - grouping subcommands in logical sections
6061
- [custom-strings](https://github.com/DannyBen/bashly/tree/master/examples/custom-strings#readme) - configuring the script's error and usage texts
6162
- [custom-includes](https://github.com/DannyBen/bashly/tree/master/examples/custom-includes#readme) - adding and organizing your custom functions
6263
- [custom-script-header](https://github.com/DannyBen/bashly/tree/master/examples/custom-script-header#readme) - configuring a different script header
@@ -79,7 +80,7 @@ All examples are listed below for convenience.
7980
## Real-world-like examples
8081

8182
- [docker-like](https://github.com/DannyBen/bashly/tree/master/examples/docker-like#readme) - a sample script with deep commands (like `docker container run`)
82-
- [git-like](https://github.com/DannyBen/bashly/tree/master/examples/git-like#readme) - a sample script with sub-commands similar to git
83+
- [git-like](https://github.com/DannyBen/bashly/tree/master/examples/git-like#readme) - a sample script with subcommands similar to git
8384

8485
## Documentation generation
8586

src/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ language.
1818

1919
## How it works
2020

21-
1. You provide a YAML configuration file, describing commands, sub-commands,
21+
1. You provide a YAML configuration file, describing commands, subcommands,
2222
arguments, and flags. Running `bashly init` creates an initial sample YAML
2323
file for you ([example](https://github.com/DannyBen/bashly/tree/master/examples/minimal#bashlyyml)).
2424
2. Bashly then automatically generates a bash script (when you run
@@ -33,11 +33,11 @@ Bashly is responsible for:
3333

3434
- Generating a **single, standalone bash script**.
3535
- Generating a **human readable, shellcheck-compliant and shfmt-compliant script**.
36-
- Generating **usage texts** and help screens, showing your tool's arguments, flags and commands (works for sub-commands also).
36+
- Generating **usage texts** and help screens, showing your tool's arguments, flags and commands (works for subcommands also).
3737
- Parsing the user's command line and extracting:
3838
- Optional or required **positional arguments**.
3939
- Optional or required **option flags** (with or without flag arguments).
40-
- **Commands** (and sub-commands).
40+
- **Commands** (and subcommands).
4141
- Standard flags (like **--help** and **--version**).
4242
- Preventing your script from running unless the command line is valid.
4343
- Providing you with a place to input your code for each of the functions your tool performs, and merging it back to the final script.

test/aspell-custom-dict.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ img
4343
ini
4444
INI
4545
init
46+
instagram
47+
json
4648
kbgrep
4749
knowledgebases
4850
libyaml
@@ -75,6 +77,7 @@ shfmt
7577
src
7678
stdin
7779
subcommand
80+
subcommands
7881
sudo
7982
Suy
8083
td
@@ -91,6 +94,7 @@ YAML
9194
yml
9295
yourcli
9396
yourscript
97+
youtube
9498
ZSH
9599
Zsh
96100
zsh

0 commit comments

Comments
 (0)