Skip to content

Commit

Permalink
fix(wt): print help message if 'help' or '--help' is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
EdenEast committed Nov 22, 2023
1 parent 4612081 commit ba6c3b4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bin/git-wt
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,13 @@ EOF

function cmd_help() {
if [[ $1 =~ $INTERNAL_COMMANDS ]]; then
$1 '--help'
CMD_HELP=true
"cmd_$1" '--help'
fi

set +e
local msg
IFS='' read -r -d '' msg <<EOF
IFS='' read -r -d '' help_msg <<EOF
Utility script to work with git worktree's
USAGE:
Expand All @@ -245,14 +246,14 @@ OPTIONS:
EOF
set -e

printf "%s\n" "$msg"
printf "%s\n" "$help_msg"
exit 1
}

function cmd_list() {
set +e
local msg
IFS='' read -r -d '' msg <<EOF
IFS='' read -r -d '' help_msg <<EOF
List worktrees
USAGE:
Expand Down Expand Up @@ -284,7 +285,7 @@ EOF
function cmd_new() {
set +e
local msg
IFS='' read -r -d '' msg <<EOF
IFS='' read -r -d '' help_msg <<EOF
Create a new branch using worktrees
USAGE:
Expand Down Expand Up @@ -330,7 +331,7 @@ EOF
function cmd_remove() {
set +e
local msg
IFS='' read -r -d '' msg <<EOF
IFS='' read -r -d '' help_msg <<EOF
Remove worktree
USAGE:
Expand Down Expand Up @@ -385,7 +386,7 @@ EOF
function cmd_root() {
set +e
local msg
IFS='' read -r -d '' msg <<EOF
IFS='' read -r -d '' help_msg <<EOF
Return the root of the repository
USAGE:
Expand Down

0 comments on commit ba6c3b4

Please sign in to comment.