Skip to content

Commit

Permalink
Make wd use exit codes without yeeting terminal (#138)
Browse files Browse the repository at this point in the history
* fix: return erroring exit codes with the set exit value

* feat!: remove the debug mode flag option
  • Loading branch information
zimeg authored Sep 13, 2024
1 parent 74404a3 commit 2b5f0e8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 20 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,6 @@ wd --version
wd --config ./file <command>
```
* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required for testing/debugging.
```zsh
wd --debug <command>
```
* Silence all output:
```zsh
Expand Down
3 changes: 1 addition & 2 deletions test/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ WD_PATH=${PWD}/..

wd()
{
# run the local wd in debug mode
"${WD_PATH}"/wd.sh -d "$@"
"${WD_PATH}"/wd.sh "$@"
}

# MacOS's `wc` command adds extra padding to the front of the command.
Expand Down
3 changes: 0 additions & 3 deletions wd.1
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ Print the running version.
.IP "-c, --config"
Specifically set the config file (default `~/.warprc`), which is useful when testing.
.
.IP "-d, --debug"
Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required when testing/debugging.
.
.IP "-q, --quiet"
Silence all output.
.
Expand Down
10 changes: 1 addition & 9 deletions wd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ Commands:
clean Remove points warping to nonexistent directories (will prompt unless --force is used)
-v | --version Print version
-d | --debug Exit after execution with exit codes (for testing)
-c | --config Specify config file (default ~/.warprc)
-q | --quiet Suppress all output
-f | --force Allows overwriting without warning (for add & clean)
Expand Down Expand Up @@ -426,7 +425,6 @@ wd_export_static_named_directories() {
WD_CONFIG=${WD_CONFIG:-$HOME/.warprc}
local WD_QUIET=0
local WD_EXIT_CODE=0
local WD_DEBUG=0

# Parse 'meta' options first to avoid the need to have them before
# other commands. The `-D` flag consumes recognized options so that
Expand All @@ -436,7 +434,6 @@ zparseopts -D -E \
c:=wd_alt_config -config:=wd_alt_config \
q=wd_quiet_mode -quiet=wd_quiet_mode \
v=wd_print_version -version=wd_print_version \
d=wd_debug_mode -debug=wd_debug_mode \
f=wd_force_mode -force=wd_force_mode

if [[ ! -z $wd_print_version ]]
Expand Down Expand Up @@ -583,9 +580,4 @@ unset args
unset points
unset val &> /dev/null # fixes issue #1

if [[ -n $wd_debug_mode ]]
then
exit $WD_EXIT_CODE
else
unset wd_debug_mode
fi
return $WD_EXIT_CODE

0 comments on commit 2b5f0e8

Please sign in to comment.