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
function usage() {
echo -e "Usage: dotbare fadd [-h] [-f] [-d] ...\n"
echo -e "Select files/directories or modified files through fzf."
echo -e "Stage the selected file to the dotfile gitbare repo.\n"
echo -e "Default: list all modified files and stage the selected files.\n"
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit."
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."
echo -e "Usage: dotbare fadd [-h] [-f] [-d] ...
Select files/directories or modified files through fzf.
Stage the selected file to the dotfile gitbare repo.
Default: list all modified files and stage the selected files.
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
function usage() {
echo -e "Usage: dotbare fbackup [-h] [-m] [-s] [-p PATH] ...\n"
echo -e "Backup files to ${DOTBARE_BACKUP}."
echo -e "This is useful when untracking files or migrating to new machines.\n"
echo -e "Default: backup all tracked files using cp command to ${DOTBARE_BACKUP} directory.\n"
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit."
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."
echo -e " -m, --move\t\tuse 'mv' instead of the default 'cp' command to backup."
echo -e "Usage: dotbare fbackup [-h] [-m] [-s] [-p PATH] ...
Backup files to ${DOTBARE_BACKUP}.
This is useful when untracking files or migrating to new machines.
Default: backup all tracked files using cp command to ${DOTBARE_BACKUP} directory.
optional arguments:
-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
function usage() {
echo -e "Usage: dotbare fcheckout [-h] [-s] [-b] [-c] [-y] ...\n"
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)."
echo -e "Branch: switch to the selected branch."
echo -e "Commit: switch to a specific commit.\n"
echo -e "Default: list all modified files and reset selected files back to HEAD.\n"
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit."
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."
echo -e " -c, --commit\t\tlist all commits and checkout selected commit."
echo -e " -y, --yes\t\tacknowledge all actions that will be taken and skip confirmation."
echo -e "Usage: dotbare fcheckout [-h] [-s] [-b] [-c] [-y] ...
Select files/commit/branch through fzf and checkout the selected objects.
Files: checkout the version in HEAD or in a specific commit (reset files content back to the selected commit).
Branch: switch to the selected branch.
Commit: switch to a specific commit.
Default: list all modified files and reset selected files back to HEAD.
Optional arguments:
-h, --help\t\tshow this help message and exit.
-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"

@ -21,13 +21,16 @@ source "${mydir}"/../helper/set_variable.sh
source "${mydir}"/../helper/git_query.sh
function usage() {
echo -e "Usage: dotbare fedit [-h] [-m] [-c] ...\n"
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"
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit."
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."
echo -e "Usage: dotbare fedit [-h] [-m] [-c] ...
Select files/commits through fzf and edit selected files/commits in EDITOR.
Default: list all tracked dotfiles and edit the selected files.
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"

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

@ -25,17 +25,20 @@ source "${mydir}"/../helper/git_query.sh
source "${mydir}"/../helper/get_confirmation.sh
function usage() {
echo -e "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] [-y] ...\n"
echo -e "Interactive log viewer with action menu."
echo -e "Action menu contains options including revert|reset|edit|checkout|exit.\n"
echo -e "Default: list all commits and prompt a menu to select action to perform.\n"
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit."
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."
echo -e " -e, --edit\t\tedit selected commit through interactive rebase and skip action menu."
echo -e " -c, --checkout\tcheckout selected commit and skip action menu."
echo -e " -y, --yes\t\tacknowledge all actions that will be taken and skip confirmation."
echo -e "Usage: dotbare flog [-h] [-r] [-R] [-e] [-c] [-y] ...
Interactive log viewer with action menu.
Action menu contains options including revert|reset|edit|checkout|exit.
Default: list all commits and prompt a menu to select action to perform.
Optional arguments:
-h, --help\t\tshow this help message and exit.
-r, --revert\t\trevert the selected commit and skip action menu.
-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
function usage() {
echo -e "Usage: dotbare freset [-h] [-c] [-S] [-H] [-y] ...\n"
echo -e "Reset(unstage) the selected staged files."
echo -e "Reset the HEAD to certain commits by using -c flag.\n"
echo -e "Default: unstage the selected files.\n"
echo -e "optional arguments:"
echo -e " -h, --help\t\tshow this help message and exit."
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."
echo -e " -H, --hard\t\treset commit using --hard flag, reset HEAD to certain commit discard all changes from the working tree."
echo -e " -y, --yes\t\tacknowledge all actions that will be taken and skip confirmation."
echo -e "Usage: dotbare freset [-h] [-c] [-S] [-H] [-y] ...
Reset(unstage) the selected staged files.
Reset the HEAD to certain commits by using -c flag.
Default: unstage the selected files.
Optional arguments:
-h, --help\t\tshow this help message and exit.
-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"

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

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

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

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

Loading…
Cancel
Save