Skip to content

Commit

Permalink
Implement feature: help
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrib committed Nov 28, 2019
1 parent fdeb70f commit 8565bc2
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions bin/droller
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ DIRECTORY="$HOME/.config/droller"
INDEX="$DIRECTORY/index"
HEAD="$DIRECTORY/head"

## usage: droller [s | o | 1 | -1 | ranking | edit | | <uri> | d | h]
## [status | s] # Show the selected record # Example: droller s
## [open | o] # Open the selected record # Example: droller o
## [+1 | 1] # +1 to the selected record # Example: droller 1
## [-1 | -] # -1 to the selected record # Example: droller -1
## [ranking] # Show the ranking table # Example: droller ranking
## [random | ] # Show the ranking table # Example: droller
## [edit | e] # Edit the index file # Example: droller edit
## [<uri>] # Add a record to the index file # Example: droller http://www...
## [delete | d] # Delete a record from the index file # Example: droller d
## [help | h] # Help # Example: droller h

main() {
createFiles

Expand All @@ -20,10 +32,10 @@ main() {
plusOnePoint -1
checkStatus
;;
"rank"|"ranking")
"ranking")
ranking
;;
"random"|"r"|"")
"random"|"")
selectRandomRecord
checkStatus
;;
Expand All @@ -38,7 +50,7 @@ main() {
checkStatus
;;
"help"|"h")
echo "help";;
showHelp;;
*)
addRecord $1;;
esac
Expand Down Expand Up @@ -125,5 +137,10 @@ getTitleFromUri() {
curl -s $uri | egrep -o '<title>[^<]*?</title>' | sed -E 's,</?title>,,g'
}

showHelp() {
egrep '#{2} usage:' $BASH_SOURCE | sed 's/##//'
egrep '## \[' $BASH_SOURCE | column -ts'#'
}

main $@

0 comments on commit 8565bc2

Please sign in to comment.