Skip to content

Commit 4380a83

Browse files
committed
chore: Documentation and minor tweaks
1 parent 639649f commit 4380a83

File tree

7 files changed

+14
-38
lines changed

7 files changed

+14
-38
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
root = true
2+
13
[*]
24
indent_style = tab
35
indent_size = 4

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
* text=auto
2-
.glue linguist-generated
2+
.glue/ linguist-generated

.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
package/aur/**
2-
package/deb/**
3-
package/rpm/**
4-
!package/*/run.sh
5-
!package/*/toast.yml
6-
!package/*/PKGBUILD
7-
!package/*/*.spec
8-
.glue/
1+
.basalt/

docs/reference.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ An array that contains every argument or flag after the first `--`
1111
```sh
1212
declare -a argsPostHyphen=()
1313

14-
source bash-args parse --port 3005 -- ls -L --color=always /lib <<-'EOF'
14+
bash-args parse --port 3005 -- ls -L --color=always /lib <<-'EOF'
1515
@flag [port] {3000} - The port to open on
1616
EOF
1717

@@ -26,7 +26,7 @@ A string that is a copy of standard input to `bash-args`
2626
```sh
2727
declare argsRawSpec=
2828

29-
source bash-args parse --port 3005 <<-'EOF'
29+
bash-args parse --port 3005 <<-'EOF'
3030
@flag [port] {3000} - The port to open on
3131
@flag [version.v] - Prints program version
3232
EOF
@@ -43,14 +43,14 @@ An associative array that contains the values of arguments
4343
```sh
4444
declare -A args=()
4545

46-
source bash-args parse --port 3005 <<-'EOF'
46+
bash-args parse --port 3005 <<-'EOF'
4747
@flag [port.p] {3000} - The port to open on
4848
EOF
4949

5050
echo "${args[port]} ${args[p]}"
5151
# 3005 3005
5252

53-
source bash-args parse -p 3005 <<-'EOF'
53+
bash-args parse -p 3005 <<-'EOF'
5454
@flag [port.p] {3000} - The port to open on
5555
EOF
5656

@@ -65,7 +65,7 @@ An array contaning all the commands supplied
6565
```sh
6666
declare -a argsCommands=()
6767

68-
source bash-args parse --port 3005 serve --user admin now --enable-security <<-'EOF'
68+
bash-args parse --port 3005 serve --user admin now --enable-security <<-'EOF'
6969
@flag [port.p] {3000} - The port to open on
7070
EOF
7171

@@ -78,7 +78,7 @@ echo "${argsCommands[*]}"
7878
The full generated help text
7979

8080
```sh
81-
source bash-args parse parse "$@" <<-"EOF"
81+
bash-args parse parse "$@" <<-"EOF"
8282
@flag [port.p] {3000} - The port to open on
8383
EOF
8484

docs/troubleshooting.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ If you are receiving opaque errors, the following may help
77
Ensure `args` exists as an associate array and NOT an index array. Create it _before_ calling out to `bash-args`
88

99

10+
## Using indexed arrays instead of associative arrays
11+
1012
```sh
1113
# Wrong
1214
declare -a args
@@ -15,22 +17,6 @@ declare -a args
1517
declare -A args
1618
```
1719

18-
## Not sourcing `bash-args`
19-
20-
If you do not source `bash-args` the variables that it sets will not be available to your current shell execution context
21-
22-
```sh
23-
# Wrong
24-
bash-args parse "$@" <<-"EOF"
25-
@flag [port.p] {3000} - The port to open on
26-
EOF
27-
28-
# Correct
29-
source bash-args parse parse "$@" <<-"EOF"
30-
@flag [port.p] {3000} - The port to open on
31-
EOF
32-
```
33-
3420
## Not declaring variables
3521

3622
TODO: test this

load.bash

Lines changed: 0 additions & 7 deletions
This file was deleted.

pkg/source/bash-args.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# shellcheck shell=bash
22

3+
# TODO: use snake_case
4+
35
bash-args() {
46
case "$1" in
57
-h|--help)

0 commit comments

Comments
 (0)