mirror of
https://github.com/jimeh/stub.sh.git
synced 2026-02-19 13:46:40 +00:00
Improve function comments by making them more tomdoc-like
This commit is contained in:
17
stub.sh
17
stub.sh
@@ -24,14 +24,15 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
# Stub given command, echoing a default stub message.
|
# Public: Stub given command, echoing a default stub message.
|
||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# - $1: Name of command to stub.
|
# - $1: Name of command to stub.
|
||||||
# - $2: When set to "STDERR", echo to STDERR instead of STDOUT.
|
# - $2: When set to "STDERR", echo to STDERR instead of STDOUT.
|
||||||
# When set to "null", all output is redirected to /dev/null.
|
# When set to "null", all output is redirected to /dev/null.
|
||||||
#
|
#
|
||||||
#
|
# Echoes nothing.
|
||||||
|
# Returns nothing.
|
||||||
stub() {
|
stub() {
|
||||||
local redirect="null"
|
local redirect="null"
|
||||||
if [ "$2" == "stdout" ] || [ "$2" == "STDOUT" ]; then redirect=""; fi
|
if [ "$2" == "stdout" ] || [ "$2" == "STDOUT" ]; then redirect=""; fi
|
||||||
@@ -41,7 +42,7 @@ stub() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Stub given command, and echo given string.
|
# Public: Stub given command, and echo given string.
|
||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# - $1: Name of command to stub.
|
# - $1: Name of command to stub.
|
||||||
@@ -49,6 +50,8 @@ stub() {
|
|||||||
# - $3: When set to "STDERR", echo to STDERR instead of STDOUT.
|
# - $3: When set to "STDERR", echo to STDERR instead of STDOUT.
|
||||||
# When set to "null", all output is redirected to /dev/null.
|
# When set to "null", all output is redirected to /dev/null.
|
||||||
#
|
#
|
||||||
|
# Echoes nothing.
|
||||||
|
# Returns nothing.
|
||||||
stub_and_echo() {
|
stub_and_echo() {
|
||||||
local redirect=""
|
local redirect=""
|
||||||
if [ "$3" == "stderr" ] || [ "$3" == "STDERR" ]; then redirect=" 1>&2"; fi
|
if [ "$3" == "stderr" ] || [ "$3" == "STDERR" ]; then redirect=" 1>&2"; fi
|
||||||
@@ -58,12 +61,14 @@ stub_and_echo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Stub given command, and execute given string with eval.
|
# Public: Stub given command, and execute given string with eval.
|
||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# - $1: Name of command to stub.
|
# - $1: Name of command to stub.
|
||||||
# - $2: String to eval when stub is called.
|
# - $2: String to eval when stub is called.
|
||||||
#
|
#
|
||||||
|
# Echoes nothing.
|
||||||
|
# Returns nothing.
|
||||||
stub_and_eval() {
|
stub_and_eval() {
|
||||||
local cmd="$1"
|
local cmd="$1"
|
||||||
|
|
||||||
@@ -87,11 +92,13 @@ stub_and_eval() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Restore the original command/function that was stubbed.
|
# Public: Restore the original command/function that was stubbed.
|
||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# - $1: Name of command to restore.
|
# - $1: Name of command to restore.
|
||||||
#
|
#
|
||||||
|
# Echoes nothing.
|
||||||
|
# Returns nothing.
|
||||||
restore() {
|
restore() {
|
||||||
local cmd="$1"
|
local cmd="$1"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user