style: change the way how usage print the help info

pull/19/head
Kevin Zhuang 4 years ago
parent 0a81217772
commit 8f69044794

@ -21,14 +21,17 @@ source "${mydir}"/../helper/set_variable.sh
source "${mydir}"/../helper/git_query.sh source "${mydir}"/../helper/git_query.sh
function usage() { function usage() {
echo -e "Usage: dotbare fadd [-h] [-f] [-d] ...\n" echo -e "Usage: dotbare fadd [-h] [-f] [-d] ...
echo -e "Select files/directories or modified files through fzf."
echo -e "Stage the selected file to the dotfile gitbare repo.\n" Select files/directories or modified files through fzf.
echo -e "Default: list all modified files and stage the selected files.\n" Stage the selected file to the dotfile gitbare repo.
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit." Default: list all modified files and stage the selected files.
echo -e " -f, --file\t\tselect files in current directory and stage the selected files."
echo -e " -d, --dir\t\tselect folders in current directory and stage the selected folders." Optional arguments:
-h, --help\t\tshow this help message and exit.
-f, --file\t\tselect files in current directory and stage the selected files.
-d, --dir\t\tselect folders in current directory and stage the selected folders."
} }
####################################### #######################################

@ -22,15 +22,18 @@ source "${mydir}"/../helper/set_variable.sh
source "${mydir}"/../helper/git_query.sh source "${mydir}"/../helper/git_query.sh
function usage() { function usage() {
echo -e "Usage: dotbare fbackup [-h] [-m] [-s] [-p PATH] ...\n" echo -e "Usage: dotbare fbackup [-h] [-m] [-s] [-p PATH] ...
echo -e "Backup files to ${DOTBARE_BACKUP}."
echo -e "This is useful when untracking files or migrating to new machines.\n" Backup files to ${DOTBARE_BACKUP}.
echo -e "Default: backup all tracked files using cp command to ${DOTBARE_BACKUP} directory.\n" This is useful when untracking files or migrating to new machines.
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit." Default: backup all tracked files using cp command to ${DOTBARE_BACKUP} directory.
echo -e " -s, --select\t\tlist all tracked files and only backup the selected files."
echo -e " -p PATH, --path PATH\tsepcify path of files to backup." optional arguments:
echo -e " -m, --move\t\tuse 'mv' instead of the default 'cp' command to backup." -h, --help\t\tshow this help message and exit.
-s, --select\t\tlist all tracked files and only backup the selected files.
-p PATH, --path PATH\tsepcify path of files to backup.
-m, --move\t\tuse 'mv' instead of the default 'cp' command to backup."
} }
####################################### #######################################

@ -25,18 +25,21 @@ source "${mydir}"/../helper/get_confirmation.sh
source "${mydir}"/../helper/git_query.sh source "${mydir}"/../helper/git_query.sh
function usage() { function usage() {
echo -e "Usage: dotbare fcheckout [-h] [-s] [-b] [-c] [-y] ...\n" echo -e "Usage: dotbare fcheckout [-h] [-s] [-b] [-c] [-y] ...
echo -e "Select files/commit/branch through fzf and checkout the selected objects."
echo -e "Files: checkout the version in HEAD or in a specific commit (reset files content back to the selected commit)." Select files/commit/branch through fzf and checkout the selected objects.
echo -e "Branch: switch to the selected branch." Files: checkout the version in HEAD or in a specific commit (reset files content back to the selected commit).
echo -e "Commit: switch to a specific commit.\n" Branch: switch to the selected branch.
echo -e "Default: list all modified files and reset selected files back to HEAD.\n" Commit: switch to a specific commit.
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit." Default: list all modified files and reset selected files back to HEAD.
echo -e " -s, --select\t\tlist all tracked files and select a commit to checkout the selected files."
echo -e " -b, --branch\t\tlist all branch and checkout/switch the selected branch." Optional arguments:
echo -e " -c, --commit\t\tlist all commits and checkout selected commit." -h, --help\t\tshow this help message and exit.
echo -e " -y, --yes\t\tacknowledge all actions that will be taken and skip confirmation." -s, --select\t\tlist all tracked files and select a commit to checkout the selected files.
-b, --branch\t\tlist all branch and checkout/switch the selected branch.
-c, --commit\t\tlist all commits and checkout selected commit.
-y, --yes\t\tacknowledge all actions that will be taken and skip confirmation."
} }
action_type="modified" action_type="modified"

@ -21,13 +21,16 @@ source "${mydir}"/../helper/set_variable.sh
source "${mydir}"/../helper/git_query.sh source "${mydir}"/../helper/git_query.sh
function usage() { function usage() {
echo -e "Usage: dotbare fedit [-h] [-m] [-c] ...\n" echo -e "Usage: dotbare fedit [-h] [-m] [-c] ...
echo -e "Select files/commits through fzf and edit selected files/commits in EDITOR.\n"
echo -e "Default: list all tracked dotfiles and edit the selected files.\n" Select files/commits through fzf and edit selected files/commits in EDITOR.
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit." Default: list all tracked dotfiles and edit the selected files.
echo -e " -m, --modified\tonly list and edit selected modified files."
echo -e " -c, --commit\t\tlist commit and edit the selected commit through interactive rebase." Optional arguments:
-h, --help\t\tshow this help message and exit.
-m, --modified\tonly list and edit selected modified files.
-c, --commit\t\tlist commit and edit the selected commit through interactive rebase."
} }
edit_type="all" edit_type="all"

@ -22,20 +22,22 @@ source "${mydir}"/../helper/set_variable.sh
source "${mydir}"/../helper/get_confirmation.sh source "${mydir}"/../helper/get_confirmation.sh
function usage() { function usage() {
echo -e "Usage: dotbare finit [-h] [-y] [-s] [-u URL] ...\n" echo -e "Usage: dotbare finit [-h] [-y] [-s] [-u URL] ...
echo -e "Init the git bare repository if doesn't exist or migrate existing dotfiles to current system."
# shellcheck disable=SC2016 Init the git bare repository if doesn't exist or migrate existing dotfiles to current system.
echo -e 'The bare repository will be initialised under $DOTBARE_DIR, default to $HOME/.cfg if not set.' The bare repository will be initialised under \$DOTBARE_DIR, default to \$HOME/.cfg if not set.
# shellcheck disable=SC2016 It will track \$DOTBARE_TREE, default to \$HOME if not set.
echo -e 'It will track $DOTBARE_TREE, default to $HOME if not set.\n'
echo -e "Migration example:" Migration example:
echo -e "dotbare finit -u URL --submodule\n" dotbare finit -u URL --submodule
echo -e "Default: init the bare repository at $DOTBARE_DIR.\n"
echo -e "optional arguments:" Default: init the bare repository at $DOTBARE_DIR.
echo -e " -h, --help\t\tshow this help message and exit."
echo -e " -u URL, --url URL\tmigrate existing dotfiles from remote git repo to current system." Optional arguments:
echo -e " -s, --submodule\tclone submodules during migration." -h, --help\t\tshow this help message and exit.
echo -e " -y, --yes\t\tacknowledge all actions that will be taken and skip confirmation." -u URL, --url URL\tmigrate existing dotfiles from remote git repo to current system.
-s, --submodule\tclone submodules during migration.
-y, --yes\t\tacknowledge all actions that will be taken and skip confirmation."
} }
remote_url="" remote_url=""

@ -25,17 +25,20 @@ source "${mydir}"/../helper/git_query.sh
source "${mydir}"/../helper/get_confirmation.sh source "${mydir}"/../helper/get_confirmation.sh
function usage() { function usage() {
echo -e "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] [-y] ...\n" echo -e "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] [-y] ...
echo -e "Interactive log viewer with action menu."
echo -e "Action menu contains options including revert|reset|edit|checkout|exit.\n" Interactive log viewer with action menu.
echo -e "Default: list all commits and prompt a menu to select action to perform.\n" Action menu contains options including revert|reset|edit|checkout|exit.
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit." Default: list all commits and prompt a menu to select action to perform.
echo -e " -r, --revert\t\trevert the selected commit and skip action menu."
echo -e " -R, --reset\t\treset HEAD back to selected commit and skip action menu." Optional arguments:
echo -e " -e, --edit\t\tedit selected commit through interactive rebase and skip action menu." -h, --help\t\tshow this help message and exit.
echo -e " -c, --checkout\tcheckout selected commit and skip action menu." -r, --revert\t\trevert the selected commit and skip action menu.
echo -e " -y, --yes\t\tacknowledge all actions that will be taken and skip confirmation." -R, --reset\t\treset HEAD back to selected commit and skip action menu.
-e, --edit\t\tedit selected commit through interactive rebase and skip action menu.
-c, --checkout\tcheckout selected commit and skip action menu.
-y, --yes\t\tacknowledge all actions that will be taken and skip confirmation."
} }
####################################### #######################################

@ -27,16 +27,19 @@ source "${mydir}"/../helper/get_confirmation.sh
source "${mydir}"/../helper/git_query.sh source "${mydir}"/../helper/git_query.sh
function usage() { function usage() {
echo -e "Usage: dotbare freset [-h] [-c] [-S] [-H] [-y] ...\n" echo -e "Usage: dotbare freset [-h] [-c] [-S] [-H] [-y] ...
echo -e "Reset(unstage) the selected staged files."
echo -e "Reset the HEAD to certain commits by using -c flag.\n" Reset(unstage) the selected staged files.
echo -e "Default: unstage the selected files.\n" Reset the HEAD to certain commits by using -c flag.
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit." Default: unstage the selected files.
echo -e " -c, --commit\t\treset HEAD to certain commit, default --mixed flag, reset HEAD to certain commit put all changes into modified state."
echo -e " -S, --soft\t\treset commit using --soft flag, reset HEAD to certain commit without modify working tree." Optional arguments:
echo -e " -H, --hard\t\treset commit using --hard flag, reset HEAD to certain commit discard all changes from the working tree." -h, --help\t\tshow this help message and exit.
echo -e " -y, --yes\t\tacknowledge all actions that will be taken and skip confirmation." -c, --commit\t\treset HEAD to certain commit, default --mixed flag, reset HEAD to certain commit put all changes into modified state.
-S, --soft\t\treset commit using --soft flag, reset HEAD to certain commit without modify working tree.
-H, --hard\t\treset commit using --hard flag, reset HEAD to certain commit discard all changes from the working tree.
-y, --yes\t\tacknowledge all actions that will be taken and skip confirmation."
} }
reset_option="--mixed" reset_option="--mixed"

@ -24,14 +24,17 @@ source "${mydir}"/../helper/get_confirmation.sh
source "${mydir}"/../helper/git_query.sh source "${mydir}"/../helper/git_query.sh
function usage() { function usage() {
echo -e "Usage: dotbare fstash [-h] [-s] [-d] [-p] ...\n" echo -e "Usage: dotbare fstash [-h] [-s] [-d] [-p] ...
echo -e "View and manage stash interactively.\n"
echo -e "Default: list all stashes and apply the selected stash.\n" View and manage stash interactively.
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit." Default: list all stashes and apply the selected stash.
echo -e " -s, --select\t\tlist modified files and stash the selected files."
echo -e " -d, --delete\t\tlist all stashes and delete the selected stash from stash list." Optional arguments:
echo -e " -p, --pop\t\tuse 'stash pop' instead of 'stash apply'." -h, --help\t\tshow this help message and exit.
-s, --select\t\tlist modified files and stash the selected files.
-d, --delete\t\tlist all stashes and delete the selected stash from stash list.
-p, --pop\t\tuse 'stash pop' instead of 'stash apply'."
} }
stash_command="apply" stash_command="apply"

@ -20,11 +20,13 @@ source "${mydir}"/../helper/set_variable.sh
source "${mydir}"/../helper/git_query.sh source "${mydir}"/../helper/git_query.sh
function usage() { function usage() {
echo -e "Usage: dotbare fstat [-h] ...\n" echo -e "Usage: dotbare fstat [-h] ...
echo -e "Display interactive git status menu."
echo -e "Toggle file stage/unstage interactively.\n" Display interactive git status menu.
echo -e "optional arguments:" Toggle file stage/unstage interactively.
echo -e " -h, --help\t\tshow this help message and exit."
Optional arguments:
-h, --help\t\tshow this help message and exit."
} }
while [[ "$#" -gt 0 ]]; do while [[ "$#" -gt 0 ]]; do

@ -23,20 +23,25 @@ source "${mydir}"/../helper/git_query.sh
source "${mydir}"/../helper/get_confirmation.sh source "${mydir}"/../helper/get_confirmation.sh
function usage() { function usage() {
echo -e "Usage: dotbare funtrack [-h] [-t] [-r] [-y] ...\n" echo -e "Usage: dotbare funtrack [-h] [-t] [-r] [-y] ...
echo -e "Untrack selected files from git.\n"
echo -e "Default: list all tracked files and permanently untrack the selected files (using git rm --cached filename).\n" Untrack selected files from git.
echo -e "Files will be remove from index while keeping the file in your current system."
echo -e "However, when your other computers pull down the changes, the untracked files will be deleted." Default: list all tracked files and permanently untrack the selected files (using git rm --cached filename).
echo -e "Make sure to run dotbare fbackup before pulling down the changes.\n"
echo -e "Alternatively use the -t flag (using git update-index --assume-unchanged [path]) to temporarily" Files will be remove from index while keeping the file in your current system.
echo -e "untrack a file but keeping the files when other computers pull down the changes." However, when your other computers pull down the changes, the untracked files will be deleted.
echo -e "More information please refere to dotbare's github.\n" Make sure to run dotbare fbackup before pulling down the changes.
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit." Alternatively use the -t flag (using git update-index --assume-unchanged [path]) to temporarily
echo -e " -t, --temp\t\tlist all tracked files and temporarily ignore changes of the selected files." untrack a file but keeping the files when other computers pull down the changes.
echo -e " -r, --resume\t\tlist all tracked files and resume tracking changes of the selected files." More information please refere to dotbare's github.
echo -e " -y, --yes\t\tacknowledge all actions that will be taken and skip confirmation."
Optional arguments:
-h, --help\t\tshow this help message and exit.
-t, --temp\t\tlist all tracked files and temporarily ignore changes of the selected files.
-r, --resume\t\tlist all tracked files and resume tracking changes of the selected files.
-y, --yes\t\tacknowledge all actions that will be taken and skip confirmation."
} }
track_type="untrack" track_type="untrack"

@ -7,10 +7,12 @@ set -f
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function usage() { function usage() {
echo -e "Usage: dotbare fupgrade [-h] ...\n" echo -e "Usage: dotbare fupgrade [-h] ...
echo -e "Upgrade dotbare to the latest master.\n"
echo -e "optional arguments:" Upgrade dotbare to the latest master.
echo -e " -h, --help\t\tshow this help message and exit."
Optional arguments:
-h, --help\t\tshow this help message and exit."
} }
while [[ "$#" -gt 0 ]]; do while [[ "$#" -gt 0 ]]; do

Loading…
Cancel
Save