Skip to content

Instantly share code, notes, and snippets.

@fertapric
Last active January 12, 2018 17:08
Show Gist options
  • Save fertapric/27b7d92c30049958f7d7f47138df33f7 to your computer and use it in GitHub Desktop.
Save fertapric/27b7d92c30049958f7d7f47138df33f7 to your computer and use it in GitHub Desktop.
Notes: enumerate all annotations in the current directory (TODO, FIXME, OPTIMIZE, HACK, REVIEW and README) (git compatible)

Usage

Help instructions:

$ notes --help
Enumerate all annotations: TODO, FIXME, OPTIMIZE, HACK, REVIEW, README

    * Use TODO to note missing features or functionality that should
      be added at a later date.
    * Use FIXME to note broken code that needs to be fixed.
    * Use OPTIMIZE to note slow or inefficient code that may cause
      performance problems.
    * Use HACK to note code smells where questionable coding practices
      were used and should be refactored away.
    * Use REVIEW to note anything that should be looked at to confirm
      it is working as intended. For example: REVIEW: Are we sure this
      is how the client does X currently?
    * Use other custom annotation keywords if it feels appropriate,
      but be sure to document them in your project's README or similar.

Usage: notes [OPTIONS] [ANNOTATION]

Options:
    -h, --help      Print usage

List all the default annotations (TODO, FIXME, OPTIMIZE, HACK, REVIEW and README):

$ notes
README.md: # TODO: Document...
lib/my_project/a_third_module.exs:  # HACK: ...
lib/my_project/another_module.exs:  # FIXME: ...
lib/my_project/module.exs:  # FIXME: ...
priv/repo/seeds.exs:  # TODO: ...

List a single annotation:

$ notes TODO
README.md: # TODO: Document URL: http://example.com/80b3eeeda161145079175f7975598b52
priv/repo/seeds.exs:  # TODO: ...

List a custom annotation:

$ notes FOO
README.md: # FOO: This is an example of custom annotation
#!/bin/bash
function print_help() {
echo "Enumerate all annotations: TODO, FIXME, OPTIMIZE, HACK, REVIEW, README"
echo
echo " * Use TODO to note missing features or functionality that should"
echo " be added at a later date."
echo " * Use FIXME to note broken code that needs to be fixed."
echo " * Use OPTIMIZE to note slow or inefficient code that may cause"
echo " performance problems."
echo " * Use HACK to note code smells where questionable coding practices"
echo " were used and should be refactored away."
echo " * Use REVIEW to note anything that should be looked at to confirm"
echo " it is working as intended. For example: REVIEW: Are we sure this"
echo " is how the client does X currently?"
echo " * Use other custom annotation keywords if it feels appropriate,"
echo " but be sure to document them in your project's README or similar."
echo
echo "Usage: notes [OPTIONS] [ANNOTATION]"
echo
echo "Options:"
echo " -h, --help Print usage"
exit
}
while [[ "$1" == -* ]]; do
case $1 in
-h | --help ) print_help
;;
* ) print_help
;;
esac
shift
done
function notes() {
if $(git status 2>&1 >/dev/null); then
for file in $(git ls-files); do
if [ -f $file ]; then
grep --color=always -r -e "^$1 " -e "^$1$" -e " $1 " -e " $1$" $file
fi
done
else
grep --color=always -r -e "^$1 " -e "^$1$" -e " $1 " -e " $1$" .
fi
}
case $1 in
"") notes TODO
notes FIXME
notes OPTIMIZE
notes HACK
notes REVIEW
notes README
;;
* ) notes $1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment