Skip to content

Commit

Permalink
Makes -- optional unless args reference a file
Browse files Browse the repository at this point in the history
  • Loading branch information
TekWizely committed Sep 22, 2019
1 parent fa99c42 commit 5a69fed
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 60 deletions.
17 changes: 13 additions & 4 deletions go-build-mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,35 @@ function find_module_roots() {
done
}

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
17 changes: 13 additions & 4 deletions go-build-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,35 @@ cmd=(go build -o /dev/null)

export GO111MODULE=off

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
17 changes: 13 additions & 4 deletions go-critic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@

cmd=(gocritic check)

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
17 changes: 13 additions & 4 deletions go-fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@

cmd=(gofmt -l -d)

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
17 changes: 13 additions & 4 deletions go-imports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@

cmd=(goimports -l -d)

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
17 changes: 13 additions & 4 deletions go-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@

cmd=(golint -set_exit_status)

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
17 changes: 13 additions & 4 deletions go-returns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@

cmd=(goreturns -l -d)

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
17 changes: 13 additions & 4 deletions go-test-mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,35 @@ function find_module_roots() {
done
}

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
17 changes: 13 additions & 4 deletions go-test-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,35 @@ cmd=(go test)

export GO111MODULE=off

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
17 changes: 13 additions & 4 deletions go-vet-mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,35 @@ function find_module_roots() {
done
}

OPTIONS=()
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
OPTIONS+=("$1")
shift
done

FILES=()
# Build potential options list (may just be files)
# Assume start of file list (may still be options)
#
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
FILES+=("$1")
shift
done

OPTIONS=()
# If '--' next, then files = options
#
if [ $# -gt 0 ]; then
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
shift
OPTIONS=("${FILES[@]}")
# Append to previous options
#
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
FILES=()
fi
fi

# Any remaining items are files
# Any remaining arguments are assumed to be files
#
while [ $# -gt 0 ]; do
FILES+=("$1")
Expand Down
Loading

0 comments on commit 5a69fed

Please sign in to comment.