Skip to content

Commit 6d689b9

Browse files
committed
update example readmes
1 parent b80a293 commit 6d689b9

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ Each of these examples demonstrates one aspect or feature of bashly.
4343
- [colors](colors#readme) - using the color print feature
4444
- [yaml](yaml#readme) - using the YAML reading functions
4545
- [completions](completions#readme) - adding bash completion functionality
46+
- [validations](validations#readme) - adding argument validation functions

examples/validations/README.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,61 @@ commands:
6464
### `$ ./calc -h`
6565

6666
```shell
67-
sh: 1: ./calc: not found
67+
calc - Sample application demonstrating validations
68+
69+
Usage:
70+
calc [command]
71+
calc [command] --help | -h
72+
calc --version | -v
73+
74+
Commands:
75+
add Add two numbers
76+
77+
Options:
78+
--help, -h
79+
Show this help
80+
81+
--version, -v
82+
Show version number
83+
84+
85+
86+
```
87+
88+
### `$ ./calc add 1 2 --multiply 3`
89+
90+
```shell
91+
# this file is located in 'src/add_command.sh'
92+
# code for 'calc add' goes here
93+
# you can edit it freely and regenerate (it will not be overwritten)
94+
args:
95+
- ${args[first]} = 1
96+
- ${args[--multiply]} = 3
97+
- ${args[second]} = 2
98+
99+
100+
```
101+
102+
### `$ ./calc add A`
103+
104+
```shell
105+
validation error: FIRST must be an integer
106+
107+
108+
```
109+
110+
### `$ ./calc add 1 B`
111+
112+
```shell
113+
validation error: SECOND must be an integer
114+
115+
116+
```
117+
118+
### `$ ./calc add 1 2 --multiply C`
119+
120+
```shell
121+
validation error: --multiply, -m FACTOR must be an integer
68122
69123
70124
```

0 commit comments

Comments
 (0)