From c785d98e23c56e0c1c372a7c9debb39fd6780920 Mon Sep 17 00:00:00 2001 From: kevin zhuang Date: Tue, 14 Apr 2020 17:17:42 +1000 Subject: [PATCH] update comment style --- dotbare | 11 +++--- .../{get_confirmation => get_confirmation.sh} | 0 helper/{search_file => search_file.sh} | 35 +++++++++---------- helper/{set_variable => set_variable.sh} | 10 +++--- scripts/fadd | 4 +-- scripts/fcheckout | 15 ++++---- scripts/freset | 4 +-- 7 files changed, 41 insertions(+), 38 deletions(-) rename helper/{get_confirmation => get_confirmation.sh} (100%) rename helper/{search_file => search_file.sh} (82%) rename helper/{set_variable => set_variable.sh} (61%) diff --git a/dotbare b/dotbare index fc68eb0..ff81911 100755 --- a/dotbare +++ b/dotbare @@ -7,18 +7,21 @@ # ${mydir}: string, directory of the executing script, used for sourcing helpers # ${action_command}: string, determine which script to call # Arguments -# command: command to run general git command/fadd/frm/fpop etc -# $opt: options flag -h -p etc +# action_command: sub commands dotbare should run +# General git command: log, status etc +# dotbare specific commands: fadd | frm | fpop | freset | fcheckout | help +# option flags: +# check sub commands for available option flags mydir="${0%/*}" -source "${mydir}"/helper/set_variable +source "${mydir}"/helper/set_variable.sh function usage() { echo "help" } # if no argument passed in, let git display help message -if [[ -z "$@" ]]; then +if [[ $# -eq 0 ]]; then /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" exit 0 fi diff --git a/helper/get_confirmation b/helper/get_confirmation.sh similarity index 100% rename from helper/get_confirmation rename to helper/get_confirmation.sh diff --git a/helper/search_file b/helper/search_file.sh similarity index 82% rename from helper/search_file rename to helper/search_file.sh index e35264b..2b46984 100644 --- a/helper/search_file +++ b/helper/search_file.sh @@ -1,25 +1,14 @@ #!/bin/bash # # search local file or directory taking consideration of optional dependency -# -# @params -# Globals -# search_type: string, f or d, search file or directory -# exe_fd: number, 0 or 1, check if fd is executable -# exe_tree: number, 0 or 1, check if tree is executable -# Arguments -# search_type: string, f or d, search file or directory - -function fd_exists() { - fd -V &>/dev/null - echo "$?" -} - -function tree_exists() { - tree --version &>/dev/null - echo "$?" -} +####################################### +# search local file +# Arguments: +# $1: stirng, f or d, search file or directory +# Outputs: +# A user selected file path +####################################### function search_file() { local search_type="$1" local exe_fd="$(fd_exists)" @@ -42,3 +31,13 @@ function search_file() { fi fi } + +function fd_exists() { + fd -V &>/dev/null + echo "$?" +} + +function tree_exists() { + tree --version &>/dev/null + echo "$?" +} diff --git a/helper/set_variable b/helper/set_variable.sh similarity index 61% rename from helper/set_variable rename to helper/set_variable.sh index c3fef64..6e2ad6f 100644 --- a/helper/set_variable +++ b/helper/set_variable.sh @@ -4,11 +4,11 @@ # # @params # Globals -# DOTBARE_DIR: string, location of the bare repo -# DOTBARE_TREE: string, which folder is the bare repo tracking -# DOTBARE_KEY: string, defualt key bindings -# FZF_DEFAULT_OPTS: string, update FZF_DEFAULT_OPTS to reflect dotbare changes -# DOTBARE_FZF_DEFAULT_OPTS: string, user custom setting for dotbare +# ${DOTBARE_DIR}: string, location of the bare repo +# ${DOTBARE_TREE}: string, which folder is the bare repo tracking +# ${DOTBARE_KEY}: string, defualt key bindings +# ${FZF_DEFAULT_OPTS}: string, update FZF_DEFAULT_OPTS to reflect dotbare changes +# ${DOTBARE_FZF_DEFAULT_OPTS}: string, user custom setting for dotbare [[ -z "${DOTBARE_DIR}" ]] && DOTBARE_DIR="$HOME/.cfg/" [[ -z "${DOTBARE_TREE}" ]] && DOTBARE_TREE="$HOME" diff --git a/scripts/fadd b/scripts/fadd index 3e7491b..edd3f9f 100755 --- a/scripts/fadd +++ b/scripts/fadd @@ -12,8 +12,8 @@ set -e mydir="${0%/*}" -source "${mydir}"/../helper/search_file -source "${mydir}"/../helper/set_variable +source "${mydir}"/../helper/search_file.sh +source "${mydir}"/../helper/set_variable.sh function usage() { echo -e "Usage: dotbare fadd [-h] [-f] [-d] ...\n" diff --git a/scripts/fcheckout b/scripts/fcheckout index c6d2add..cf219bc 100755 --- a/scripts/fcheckout +++ b/scripts/fcheckout @@ -1,13 +1,14 @@ #!/bin/bash # -# checkout files/commits using fzf +# checkout files/commits/branches using fzf # # @params # Globals -# all_files: search all tracked files instead of just the modified files -# branch: checkout branch -# selected_branch: selected_branch to switch -# selected_files: selected_files to checkout to the version in HEAD +# ${mydir}: current directory of the script, used for imports +# ${all_files}: search all tracked files instead of just the modified files +# ${branch}: checkout branch +# ${selected_branch}: selected_branch to switch +# ${selected_files}: selected_files to checkout to the version in HEAD # Arguments # -a: search all files instead of just the modified files # -b: search branch and checkout branch @@ -16,8 +17,8 @@ set -e mydir="${0%/*}" -source "${mydir}"/../helper/set_variable -source "${mydir}"/../helper/get_confirmation +source "${mydir}"/../helper/set_variable.sh +source "${mydir}"/../helper/get_confirmation.sh function usage() { echo -e "Usage: dotbare fcheckout [-h] [-c] [-S] [-H] ...\n" diff --git a/scripts/freset b/scripts/freset index efc974f..60de7bc 100755 --- a/scripts/freset +++ b/scripts/freset @@ -13,8 +13,8 @@ set -e mydir="${0%/*}" -source "${mydir}"/../helper/set_variable -source "${mydir}"/../helper/get_confirmation +source "${mydir}"/../helper/set_variable.sh +source "${mydir}"/../helper/get_confirmation.sh function usage() { echo -e "Usage: dotbare freset [-h] [-c] [-S] [-H] ...\n"