Skip to content

Commit

Permalink
edit suggestions on examples (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Owolabi Legunsen <legunsen@cornell.edu>
  • Loading branch information
owolabileg and Owolabi Legunsen authored Mar 12, 2024
1 parent e20794e commit 5e7da53
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions examples/anonymous_struct_ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readonly DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )


# Anonymous structs are created using `amake_` function; this function
# is the same as `make_`, but does not accept `struct` name.
# is the same as `make_`, but does not accept the `struct` name.
p=$(amake_ "x" 3 "y" 5)
$p x
# Output: 3
Expand All @@ -21,7 +21,7 @@ function demo() {
$a to_string
}
demo
# Output (different for you depending on time and random number):
# Output (will differ for you, depending on current time and a random number):
# {
# "date": "Mon 14 Aug 2023 10:22:29 AM CDT",
# "rand": "32674"
Expand Down
4 changes: 2 additions & 2 deletions examples/flags_details_ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function check_arguments() {
fi
}

# The following function is some random computation to illustrate the
# way code for parsing can be connected to other/existing code.
# The following function is some random computation to illustrate how
# code for parsing can be connected to other/existing code.
function compute_loc() {
local -r url="${1}"
shift 1
Expand Down
2 changes: 1 addition & 1 deletion examples/flags_ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ $flags $ctx parse "$data" "$@" || \
$data to_string

# Use data.
echo "Values that you provides are x=$($data x) and z=$($data z)"
echo "The values that you provided are x=$($data x) and z=$($data z)"
6 changes: 3 additions & 3 deletions examples/methods_ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ function Request_curl() {
# The first argument of each method is an instance on which
# the method was invoked (think of it as `this` or
# `self`). Subsequent arguments (if any) are given to the
# method at the invocation time.
# method at invocation time.
local -r req="${1}"
shift 1

# Body of the method can be anything.
# Exit code from this method will be propagated to the caller.
# The method body can be anything.
# The exit code from this method will be propagated to the caller.
curl "$($req url)" 2>&1
}

Expand Down
4 changes: 2 additions & 2 deletions examples/shapes_ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function Circle() {

make_ $FUNCNAME \
"r" "${r}"
# We do not need to return this explicitly (because the
# default output is the result of the latest command, but
# We do not need to return explicitly (because the
# default output is the result of the last command, but
# being explicit is good in some cases).
# return $?
}
Expand Down
8 changes: 4 additions & 4 deletions examples/structs_ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ readonly DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. ${DIR}/../gobash


# `struct` and `constructor` are one. In any future example, we will
# `struct` and `constructor` are synonyms. In future examples, we will
# only use `struct` in text (but we really mean both at once).
function Request() {
# Normal function arguments in bash.
Expand All @@ -17,10 +17,10 @@ function Request() {
# functions. `make_` allocates an instance. The first
# argument is the struct name (think of it as a type). struct
# name can be anything, but we will always use $FUNCNAME
# (which is Request in this example). Name is important when
# (which is `Request` in this example). Name is important when
# associating methods with a struct (and we love
# $FUNCNAME). The arguments that follow are pairs of a field
# name and value.
# $FUNCNAME). The arguments that follow are the name and value
# of a field.
make_ $FUNCNAME \
"url" "${url}"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/template_ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# In summary, it is valuable to always check context at the end of the
# execution (even if you do not create your own context, but you rely
# on the global context). Of course, you can combine this with your
# regular debugging using -e (which we know is limited) and -x.
# regular debugging, using -e (which is limited) and -x.

readonly DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. ${DIR}/../gobash
Expand Down
2 changes: 1 addition & 1 deletion examples/text_menu_ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function main() {
local menu=$(TextMenu "Pick your favorite color." "$lst")

local res=$(UIResult)
# Ask a user to pick an option.
# Ask a user to select an option.
$menu show "${res}"

# Result keeps the selected value.
Expand Down
4 changes: 2 additions & 2 deletions examples/to_json_ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function Person() {
p=$(Person "Jessy" 10)
$p to_json

# Although one can override the implementation of `to_json`, such
# changes are not recommended.
# Although one can override the implementation of `to_json`, doing
# so is not recommended.

# Output of this script:
# {
Expand Down
8 changes: 4 additions & 4 deletions examples/wait_group_ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ readonly DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )


function main() {
# This function illustrates the way we create and use
# This function illustrates how we create and use
# WaitGroup. However, this example does not really need
# WaitGroup as we wait for all sub processes; we can simply
# use wait command at the end of the function to wait for
# everything we spawned. The value of this example is to
# illustrate the way to create a WaitGroup, and processes to
# every process that we spawned. The value of this example is to
# illustrate how to create a WaitGroup, processes to
# it, and wait (which would be a nice approach if one has to
# wait only for a selected subset of them).
# wait only for a subset of processes).

local -r wg=$(WaitGroup)

Expand Down

0 comments on commit 5e7da53

Please sign in to comment.