-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## test | ||
|
||
### stderr | ||
``` | ||
the-cmd: | ||
the-cmd:18: Cannot use both --required and --init. | ||
the-cmd:19: Cannot use both --required and --init. | ||
the-cmd:20: Cannot use both --required and --init. | ||
Cannot process arguments, due to declaration errors. | ||
the-cmd -- test command | ||
``` | ||
|
||
### exit: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Test for error detection on `--init=... --required`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
# Copyright 2022-2023 the Bashy-lib Authors (Dan Bornstein et alia). | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
[[ "$(readlink -f "$0")" =~ ^(.*/tests/) ]] && . "${BASH_REMATCH[1]}_test-init.sh" || exit 1 | ||
|
||
cmd="$(this-cmd-dir)/the-cmd" | ||
|
||
call-and-log-as-test 'test' \ | ||
"${cmd}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# Copyright 2022-2023 the Bashy-lib Authors (Dan Bornstein et alia). | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
[[ "$(readlink -f "$0")" =~ ^(.*/tests/) ]] && . "${BASH_REMATCH[1]}_init.sh" || exit 1 | ||
|
||
|
||
# | ||
# Argument parsing | ||
# | ||
|
||
define-usage $' | ||
${name} -- test command | ||
This is a test command. | ||
' | ||
|
||
opt-value --required --var=var1 --init=florp some-value | ||
opt-choice --init=maybe --required --var=var3 yes no | ||
positional-arg --init=x --var=var4 --required some-position | ||
|
||
process-args "$@" || usage --short | ||
|
||
echo 'Nopers.' |