Skip to content

Commit

Permalink
New command bin/bashlets-methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Reale committed Feb 28, 2018
1 parent 32812ef commit 071a4e5
Showing 1 changed file with 126 additions and 0 deletions.
126 changes: 126 additions & 0 deletions bin/bashlets-methods
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/bin/bash

################################################################################
#
# | | | |
# |---.,---.,---.|---.| ,---.|--- ,---.
# | |,---|`---.| || |---'| `---.
# `---'`---^`---'` '`---'`---'`---'`---'
#
#
# bashlets -- A modular extensible toolbox for Bash
#
# List methods of a given bashlet
#
# Copyright (c) 2014-8 Roberto Reale
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
################################################################################


#
# global variables
################################################################################

BASHLETS_BASE=~/.bashlets

# verbose output
verbose=:


#
# utilities
################################################################################

function usage()
{
cat <<-EOF
Usage:
bashlets-methods
Options:
-? display this help and exit
-V output version information and exit
EOF
}

function version()
{
cat <<-EOF
bashlets-methods 0.1
EOF
}

function verbose()
{
$verbose "$@"
}


#
# core logic
################################################################################

function list_methods()
{
local bashlet="$1"
(
source bashlet library/loader
bash$$ loader list_methods "$bashlet" | sort
)
}


#
# parse command line options
################################################################################

while getopts "?V" OPTION
do
case $OPTION in
?)
echo ; version
echo ; usage
exit 0
;;
V)
version
exit 0
;;
esac
done

shift $((OPTIND-1))

[[ $# -gt 0 ]] || { usage ; exit 1 ; }

list_methods "$1"


# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh

0 comments on commit 071a4e5

Please sign in to comment.