Stylistic changes to cheat (#97)
This commit is contained in:
parent
1711e9e7a9
commit
fcd658c842
80
cheat/cheat
80
cheat/cheat
|
@ -22,7 +22,6 @@ getConfiguredClient()
|
|||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
|
@ -62,7 +61,7 @@ update()
|
|||
echo "Version $latestVersion available"
|
||||
echo -n "Do you wish to update $repositoryName [Y/n]: "
|
||||
read -r answer
|
||||
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
|
||||
if [[ "$answer" == [Yy] ]]; then
|
||||
cd ~ || { echo 'Update Failed'; exit 1; }
|
||||
if [[ -d ~/$repositoryName ]]; then rm -r -f $repositoryName || { echo "Permissions Error: try running the update as sudo"; exit 1; } ; fi
|
||||
git clone "https://github.com/$githubUserName/$repositoryName" || { echo "Couldn't download latest version" ; exit 1; }
|
||||
|
@ -84,27 +83,29 @@ update()
|
|||
|
||||
usage()
|
||||
{
|
||||
echo "Cheat"
|
||||
echo "Description: Cheatsheets for quick information about multiple programming languages along with terminal commands"
|
||||
echo "Usage: cheat [flags] [command] or cheat [flags] [programming language] [subject]"
|
||||
echo " -s Does a search for last argument rather than looking for exact match"
|
||||
echo " -i Case insensitive search"
|
||||
echo " -b Word boundaries in search"
|
||||
echo " -r Recursive search"
|
||||
echo " -u Update Bash-Snippet Tools"
|
||||
echo " -h Show the help"
|
||||
echo " -v Get the tool version"
|
||||
echo "Special Pages:"
|
||||
echo " hello Describes building the hello world program written in the language"
|
||||
echo " list This lists all cheatsheets related to previous arg if none it lists all cheatsheets"
|
||||
echo " learn Shows a learn-x-in-minutes language cheat sheet perfect for getting started with the language"
|
||||
echo " 1line A collection of one-liners in this language"
|
||||
echo " weirdness A collection of examples of weird things in this language"
|
||||
echo "Examples:"
|
||||
echo " cheat rust hello"
|
||||
echo " cheat -r -b -i go"
|
||||
echo " cheat julia Functions"
|
||||
echo " cheat -i go operators"
|
||||
cat <<EOF
|
||||
Cheat
|
||||
Description: Cheatsheets for quick information about multiple programming languages along with terminal commands
|
||||
Usage: cheat [flags] [command] or cheat [flags] [programming language] [subject]
|
||||
-s Does a search for last argument rather than looking for exact match
|
||||
-i Case insensitive search
|
||||
-b Word boundaries in search
|
||||
-r Recursive search
|
||||
-u Update Bash-Snippet Tools
|
||||
-h Show the help
|
||||
-v Get the tool version
|
||||
Special Pages:
|
||||
hello Describes building the hello world program written in the language
|
||||
list This lists all cheatsheets related to previous arg if none it lists all cheatsheets
|
||||
learn Shows a learn-x-in-minutes language cheat sheet perfect for getting started with the language
|
||||
1line A collection of one-liners in this language
|
||||
weirdness A collection of examples of weird things in this language
|
||||
Examples:
|
||||
cheat rust hello
|
||||
cheat -r -b -i go
|
||||
cheat julia Functions
|
||||
cheat -i go operators
|
||||
EOF
|
||||
}
|
||||
|
||||
getCheatSheet()
|
||||
|
@ -155,48 +156,38 @@ getConfiguredClient || exit 1
|
|||
checkInternet || exit 1
|
||||
|
||||
while getopts "ribuvhis" opt; do
|
||||
case $opt in
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
case "$opt" in
|
||||
\?) echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
h) usage
|
||||
exit 0
|
||||
;;
|
||||
v)
|
||||
echo "Version $currentVersion"
|
||||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u)
|
||||
update
|
||||
u) update
|
||||
exit 0
|
||||
;;
|
||||
i)
|
||||
insensitive="i"
|
||||
i) insensitive="i"
|
||||
search="1"
|
||||
;;
|
||||
b)
|
||||
boundry="b"
|
||||
b) boundry="b"
|
||||
search="1"
|
||||
;;
|
||||
r)
|
||||
recursive="r"
|
||||
r) recursive="r"
|
||||
search="1"
|
||||
;;
|
||||
s)
|
||||
search="1"
|
||||
s) search="1"
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
:) echo "Option -$OPTARG requires an argument." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
### This functions sets arg 1 and arg 2 to be unqique items after the options
|
||||
for arg
|
||||
do
|
||||
for arg; do
|
||||
if [[ $arg != "-r" && $arg != "-s" && $arg != "-b" && $arg != "-i" ]]; then
|
||||
if [ -z ${arg1+x} ]; then
|
||||
arg1=$arg
|
||||
|
@ -229,5 +220,4 @@ else
|
|||
exit 0
|
||||
fi
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue