From 41c27c4433691fd03270c9b2fc74b073034358ca Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 5 Sep 2017 02:22:58 -0400 Subject: Rewrite main mod Reflect recent changes in the main function --- main.sh | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'main.sh') diff --git a/main.sh b/main.sh index 957cc24..a23a989 100644 --- a/main.sh +++ b/main.sh @@ -9,37 +9,43 @@ function main { if [ $# -eq 0 ]; then - echo "Error: no command given" - exit + echo "Fatal: no command given" >&2 + exit 1 fi cmd="$1" shift - if [ $# -gt 1 ]; then + if [ ! -f ".systr/BASE" ]; then if [[ "$cmd" == "checkout" ]]; then systr_checkout "$@" exit fi fi - read remote <.systr/remote - read path <.systr/path - read BASE <.systr/BASE - read TRAC <.systr/TRAC + read path <.systr/path || echo "Fatal: not in a worktree" >&2 + read BASE <.systr/BASE || exit 1 + read TRAC <.systr/TRAC + read MERG <.systr/MERG + read updated <.systr/updated - if [[ "$cmd" == "checkout" ]]; then - systr_checkout "$@" - elif [[ "$cmd" == "status" ]]; then + if [[ "$cmd" == "status" ]]; then systr_status "$@" + elif [[ "$cmd" == "init" ]]; then + systr_init "$@" + elif [[ "$cmd" == "checkout" ]]; then + systr_checkout "$@" elif [[ "$cmd" == "commit" ]]; then systr_commit "$@" elif [[ "$cmd" == "tag" ]]; then systr_repo_tag "$@" + elif [[ "$cmd" == "shortlog" ]]; then + systr_short_log "$@" elif [[ "$cmd" == "log" ]]; then - systr_repo_generate_log "$@" + systr_log "$@" else - echo "Fatal: $cmd not recognized" + echo "Fatal: $cmd not recognized" >&2 + exit 1 fi } -- cgit v1.2.3