You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference.md
+19-8Lines changed: 19 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Variables
4
4
5
-
Available variables after calling `args.parse`. If the values of the variables appear to be blank, you may have to declare the variable before calling `args.parse`
5
+
Available variables after calling `bash-args`. If the values of the variables appear to be blank, you may have to declare the variable before calling `bash-args`
6
6
7
7
### `argsPostHyphen`
8
8
@@ -11,7 +11,7 @@ An array that contains every argument or flag after the first `--`
11
11
```sh
12
12
declare -a argsPostHyphen=()
13
13
14
-
source args.parse --port 3005 -- ls -L --color=always /lib <<-'EOF'
14
+
sourcebash-argsparse --port 3005 -- ls -L --color=always /lib <<-'EOF'
15
15
@flag [port] {3000} - The port to open on
16
16
EOF
17
17
@@ -21,12 +21,12 @@ echo "${argsPostHyphen[*]}"
21
21
22
22
### `argsRawSpec`
23
23
24
-
A string that is a copy of standard input to `args.parse`
24
+
A string that is a copy of standard input to `bash-args`
25
25
26
26
```sh
27
27
declare argsRawSpec=
28
28
29
-
source args.parse --port 3005 <<-'EOF'
29
+
sourcebash-argsparse --port 3005 <<-'EOF'
30
30
@flag [port] {3000} - The port to open on
31
31
@flag [version.v] - Prints program version
32
32
EOF
@@ -43,14 +43,14 @@ An associative array that contains the values of arguments
43
43
```sh
44
44
declare -A args=()
45
45
46
-
source args.parse --port 3005 <<-'EOF'
46
+
sourcebash-argsparse --port 3005 <<-'EOF'
47
47
@flag [port.p] {3000} - The port to open on
48
48
EOF
49
49
50
50
echo"${args[port]}${args[p]}"
51
51
# 3005 3005
52
52
53
-
source args.parse -p 3005 <<-'EOF'
53
+
sourcebash-argsparse -p 3005 <<-'EOF'
54
54
@flag [port.p] {3000} - The port to open on
55
55
EOF
56
56
@@ -65,7 +65,7 @@ An array contaning all the commands supplied
65
65
```sh
66
66
declare -a argsCommands=()
67
67
68
-
source args.parse --port 3005 serve --user admin now --enable-security <<-'EOF'
68
+
sourcebash-argsparse --port 3005 serve --user admin now --enable-security <<-'EOF'
Ensure `args` exists as an associate array and NOT an index array. Create it _before_ calling out to `args.parse`
7
+
Ensure `args` exists as an associate array and NOT an index array. Create it _before_ calling out to `bash-args`
8
8
9
9
10
10
```sh
@@ -15,12 +15,24 @@ declare -a args
15
15
declare -A args
16
16
```
17
17
18
-
## Not sourcing `args.parse`
18
+
## Not sourcing `bash-args`
19
19
20
-
// TODO
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
+
```
21
33
22
34
## Not declaring variables
23
35
24
36
TODO: test this
25
37
26
-
If you wish to use a variable, please declare it before invoking `args.parse`. If your shell context has `set -u` enabled, you may have to declare it for variables that you do not use
38
+
If you wish to use a variable, please declare it before invoking `bash-args`. If your shell context has `set -u` enabled, you may have to declare it for variables that you do not use
Copy file name to clipboardExpand all lines: examples/bashblog.sh
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
# https://github.com/cfenollosa/bashblog
4
4
5
-
source args.parse <<"EOF"
5
+
sourcebash-argsparse <<"EOF"
6
6
@arg post - insert a new blog post, or the filename of a draft to continue editing it. it tries to use markdown by default, and falls back to HTML if it's not available. use '-html' to override it and edit the post as HTML even when markdown is available
7
7
@arg edit - edit an already published .html or .md file. **NEVER** edit manually a published .html file, always use this function as it keeps internal data and rebuilds the blog. use '-n' to give the file a new name, if title was changed. use '-f' to edit full html file, instead of just text part (also preserves name)
8
8
@arg delete - deletes the post and rebuilds the blog
0 commit comments