From e86c10f3ae373ba6318e0f92c4958de03bc8b9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 5 Jan 2017 17:55:18 +0100 Subject: Some fixes and some help change planned to implement --- note | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/note b/note index 1e59681..aa5b80c 100755 --- a/note +++ b/note @@ -56,7 +56,7 @@ git_commit_unmanaged() { git_commit_file_edited() { if ! check_git; then return; fi git add "$1" - if [ -n "$(git diff-index --cached --name-status HEAD \"$1\")" ]; then + if [ -n "$(git diff-index --cached --name-status HEAD -- "$1")" ]; then # No changes staged, so we can return return fi @@ -116,21 +116,23 @@ note_create() { # arguments parsing and hep ##################################################### print_help() { - echo "Usage: note [OPERATION] NOTE " + echo "Usage: note [OPTIONS] " echo "Edit and see notes from ~/.notes directory." echo - echo "Operations:" - echo " d, delete Remove given note." - echo " c, create Specifies that we want to just create note." - echo " Editor won't be opened. If such note exists," - echo " error is reported." - echo " e, edit Specifies that we want to edit given note." - echo " If note is missing, error is reported." - echo " m, move Renames given note to new TARGET_NOTE." - echo " l, less Shows note in less instead of editing it." - echo " git Executes git command in ~/.notes directory" - echo " All arguments after this operation is passed" - echo " to git call as its arguments." + echo "Options:" + echo " -d, --delete Remove given note." + echo " -c, --create Specifies that we want to just create note." + echo " Editor won't be opened. If such note exists," + echo " error is reported." + echo " -e, --edit Specifies that we want to edit given note." + echo " If note is missing, error is reported." + echo " -m, --move Renames given note to new TARGET_NOTE." + echo " -l, --less Shows note in less instead of editing it." + echo " -t, --tree Shows all notes in tree. No TARGET_NOTE is" + echo " expected for when this option is used." + echo "Git usage: note git " + echo " Executes git command in ~/.notes directory All arguments" + echo " after this operation is passed to git call as its arguments." } is_op() { @@ -152,13 +154,11 @@ while (( $# > 0 )); do ;; *) if [ -z "$OPERATION" ] && is_op "$1"; then - if [ "$1" == "git" ]; then - shift + OPERATION="$1" + shift + if [ "$OPERATION" == "git" ]; then GIT_ARGS="$@" shift $# - else - OPERATION="$1" - shift fi continue fi @@ -185,6 +185,7 @@ fi case "$OPERATION" in git) + # TODO handle git init (create initial commit otherwise errors can ocure) git $GIT_ARGS exit $? ;; -- cgit v1.2.3