Skip to content

Commit ff2b741

Browse files
committed
add usage patterns for default values
1 parent 6bad95c commit ff2b741

File tree

28 files changed

+365
-3
lines changed

28 files changed

+365
-3
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ $ gem install bashly
2626
```
2727

2828

29+
Prerequisites
30+
--------------------------------------------------
31+
32+
The bash scripts generated by bashly require bash 4 or higher due to heavy
33+
use of associative arrays.
34+
35+
2936
What is Bashly
3037
--------------------------------------------------
3138

@@ -159,6 +166,7 @@ bash function.
159166
`name` | The name of the argument.
160167
`help` | The message to display when using `--help`. Can have multiple lines.
161168
`required` | Specify if this argument is required. Note that once you define an optional argument (without required: true) then you cannot define required arguments after it.
169+
`default` | The value to use in case it is not provided by the user. Implies that this argument is optional.
162170

163171
### Flag options
164172

@@ -173,6 +181,7 @@ short form).
173181
`help` | The text to display when using `--help`. Can have multiple lines.
174182
`arg` | If the flag requires an argument, specify its name here.
175183
`required` | Specify if this flag is required.
184+
`default` | The value to use in case it is not provided by the user. Implies that this flag is optional, and only makes sense when the flag has an argument.
176185

177186
#### Special handling for -v and -h
178187

examples/colors/colorly

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ parse_requirements() {
145145

146146
esac
147147
done
148+
# :command.default_assignments
148149
}
149150

150151
# :command.initialize

examples/command-default/ftp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ parse_requirements() {
209209

210210
esac
211211
done
212+
# :command.default_assignments
212213
}
213214

214215
# :command.parse_requirements
@@ -263,6 +264,7 @@ ftp_upload_parse_requirements() {
263264

264265
esac
265266
done
267+
# :command.default_assignments
266268
}
267269

268270
# :command.parse_requirements
@@ -317,6 +319,7 @@ ftp_download_parse_requirements() {
317319

318320
esac
319321
done
322+
# :command.default_assignments
320323
}
321324

322325
# :command.initialize

examples/command-groups/ftp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ parse_requirements() {
282282

283283
esac
284284
done
285+
# :command.default_assignments
285286
}
286287

287288
# :command.parse_requirements
@@ -336,6 +337,7 @@ ftp_download_parse_requirements() {
336337

337338
esac
338339
done
340+
# :command.default_assignments
339341
}
340342

341343
# :command.parse_requirements
@@ -390,6 +392,7 @@ ftp_upload_parse_requirements() {
390392

391393
esac
392394
done
395+
# :command.default_assignments
393396
}
394397

395398
# :command.parse_requirements
@@ -432,6 +435,7 @@ ftp_login_parse_requirements() {
432435

433436
esac
434437
done
438+
# :command.default_assignments
435439
}
436440

437441
# :command.parse_requirements
@@ -474,6 +478,7 @@ ftp_logout_parse_requirements() {
474478

475479
esac
476480
done
481+
# :command.default_assignments
477482
}
478483

479484
# :command.initialize

examples/commands-nested/cli

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ parse_requirements() {
352352

353353
esac
354354
done
355+
# :command.default_assignments
355356
}
356357

357358
# :command.parse_requirements
@@ -419,6 +420,7 @@ cli_dir_parse_requirements() {
419420

420421
esac
421422
done
423+
# :command.default_assignments
422424
}
423425

424426
# :command.parse_requirements
@@ -473,6 +475,7 @@ cli_dir_list_parse_requirements() {
473475

474476
esac
475477
done
478+
# :command.default_assignments
476479
}
477480

478481
# :command.parse_requirements
@@ -533,6 +536,7 @@ cli_dir_remove_parse_requirements() {
533536

534537
esac
535538
done
539+
# :command.default_assignments
536540
}
537541

538542
# :command.parse_requirements
@@ -600,6 +604,7 @@ cli_file_parse_requirements() {
600604

601605
esac
602606
done
607+
# :command.default_assignments
603608
}
604609

605610
# :command.parse_requirements
@@ -654,6 +659,7 @@ cli_file_show_parse_requirements() {
654659

655660
esac
656661
done
662+
# :command.default_assignments
657663
}
658664

659665
# :command.parse_requirements
@@ -708,6 +714,7 @@ cli_file_edit_parse_requirements() {
708714

709715
esac
710716
done
717+
# :command.default_assignments
711718
}
712719

713720
# :command.initialize

examples/commands/cli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ parse_requirements() {
242242

243243
esac
244244
done
245+
# :command.default_assignments
245246
}
246247

247248
# :command.parse_requirements
@@ -305,6 +306,7 @@ cli_download_parse_requirements() {
305306

306307
esac
307308
done
309+
# :command.default_assignments
308310
}
309311

310312
# :command.parse_requirements
@@ -388,6 +390,7 @@ cli_upload_parse_requirements() {
388390

389391
esac
390392
done
393+
# :command.default_assignments
391394
}
392395

393396
# :command.initialize

examples/config-ini/configly

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ parse_requirements() {
382382

383383
esac
384384
done
385+
# :command.default_assignments
385386
}
386387

387388
# :command.parse_requirements
@@ -447,6 +448,7 @@ configly_set_parse_requirements() {
447448

448449
esac
449450
done
451+
# :command.default_assignments
450452
}
451453

452454
# :command.parse_requirements
@@ -501,6 +503,7 @@ configly_get_parse_requirements() {
501503

502504
esac
503505
done
506+
# :command.default_assignments
504507
}
505508

506509
# :command.parse_requirements
@@ -543,6 +546,7 @@ configly_list_parse_requirements() {
543546

544547
esac
545548
done
549+
# :command.default_assignments
546550
}
547551

548552
# :command.initialize

examples/custom-includes/download

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ parse_requirements() {
117117

118118
esac
119119
done
120+
# :command.default_assignments
120121
}
121122

122123
# :command.initialize

examples/custom-strings/download

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ parse_requirements() {
133133

134134
esac
135135
done
136+
# :command.default_assignments
136137
}
137138

138139
# :command.initialize

examples/default-values/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Minimal Example
2+
==================================================
3+
4+
This example was generated with:
5+
6+
$ bashly init --minimal
7+
$ bashly generate

0 commit comments

Comments
 (0)