Cli-love/helpme revision idea
From Pandora Wiki
idea
Simplify everything by moving all data into a separate document. This document can be made portable between the wiki and CLI Love itself.
Move the list into its own document. Then it can be downloaded with something like:
\wget http://pandorawiki.org/index.php?title=Cli-love/helpme_revision_idea&action=raw -O helpme.txt
helpme.sh
#!/bin/bash # Scan a text file # Look for given search string # If found # Print lines which have a string with spaces # Stop at the first blank line. # IDEA: Instead of directly echoing the text, build a variable. Then use `less` to display it. But frankly, if a description is that long, something is very wrong. # IDEA: Go back through the list and display all associated commands. # This would be pretty annoying to do. # Assumptions: # Commands do not have spaces in them. # TODO: Redo the text file format so that it's copy-pasteable between the text file and the wiki. echo_if_has_spaces(){ # Display lines # with a space # or starting with http pattern=\ \|^http if [[ "$1" =~ $pattern ]]; then \echo -e "$1" fi } checker() { found="false" # Scan a text file while \read line; do # Look for given search string if [[ $1 == $line ]]; then found="true" fi if [[ $found == "true" ]]; then # Stop at the first blank line. if [[ "$line" == "" ]]; then break fi # Print lines which have a string with spaces echo_if_has_spaces "$line" fi # (Scan a text file) done < <( \cat helpme.txt ) if [[ $found == "false" ]]; then \echo sorry, not found fi } checker first #checker example #checker second #checker failure
helpme.txt
first example This is an example description. It is one paragraph. \\nSlash sequences are allowed (see man echo), but must be double-escaped. \ \\\\\\ backslash \ \\\\a alert (BEL) \ \\\\b backspace \ \\\\c produce no further output \ \\\\e escape \ \\\\f form feed \ \\\\n new line \ \\\\r carriage return \ \\\\t horizontal tab \ \\\\v vertical tab \ \\\\0NNN byte with octal value NNN (1 to 3 digits) \ \\\\xHH byte with hexadecimal value HH (1 to 2 digits) Spaces at the beginning of a line must begin with a \\ \\n http://example.com http://another.org second This is a second program.