Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding verify command #387

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 107 additions & 2 deletions yadm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function main() {

# parse command line arguments
local retval=0
internal_commands="^(alt|bootstrap|clean|clone|config|decrypt|encrypt|enter|git-crypt|help|--help|init|introspect|list|perms|transcrypt|upgrade|version|--version)$"
internal_commands="^(alt|bootstrap|clean|clone|config|decrypt|encrypt|enter|echo|git-crypt|help|--help|init|introspect|list|perms|transcrypt|upgrade|version|--version)$"
if [ -z "$*" ] ; then
# no argumnts will result in help()
help
Expand Down Expand Up @@ -144,7 +144,7 @@ function main() {
[ ! -d "$YADM_WORK" ] && error_out "Work tree does not exist: [$YADM_WORK]"
HOOK_COMMAND="$YADM_COMMAND"
invoke_hook "pre"
$YADM_COMMAND "${YADM_ARGS[@]}"
${YADM_COMMAND/echo/yecho} "${YADM_ARGS[@]}"
else
# any other commands are simply passed through to git
HOOK_COMMAND="$1"
Expand Down Expand Up @@ -1117,6 +1117,7 @@ Commands:
yadm enter [COMMAND] - Run sub-shell with GIT variables set
yadm git-crypt [OPTIONS] - Run git-crypt commands for the yadm repo
yadm transcrypt [OPTIONS] - Run transcrypt commands for the yadm repo
yadm echo [OPTIONS] - View yadm internal commands and file paths

Files:
\$HOME/.config/yadm/config - yadm's configuration file
Expand Down Expand Up @@ -1400,6 +1401,110 @@ function version() {

}

function print_variables(){
local local_class
local local_system
local local_host
local local_user
local local_distro
set_local_alt_values

if [[ -z "$2" ]]; then
echo "Yadm variables:
distro=$local_distro
system=$local_system
hostname=$local_host
user=$local_user
class=$local_class
"
else
case "$2" in
class)
echo $local_class
;;
system)
echo $local_system
;;
host)
echo $local_host
;;
user)
echo $local_user
;;
distro)
echo $local_distro
;;
*)
echo "$2 is not a valid option"
esac
fi

}

function print_paths(){
if [[ -z "$2" ]] ; then
echo "yadm paths:
repo=$YADM_REPO
yadm_dir=$YADM_DIR
config=$YADM_CONFIG
encrypt=$YADM_ENCRYPT
archive=$YADM_ARCHIVE
"
else
case "$2" in
repo)
echo $YADM_REPO
;;
dir|yadm_dir)
echo $YADM_DIR
;;
config)
echo $YADM_CONFIG
;;
encrypt)
echo $YADM_ENCRYPT
;;
archive)
echo $YADM_ARCHIVE
;;
*)
echo " in path "
echo "$2 is not a valid option"
esac
fi
}

function yecho() {
#verify internal yadm variables

if [[ $# -eq 0 ]] ; then
print_variables
print_paths
fi

while [[ $# -gt 0 ]] ; do
case "$1" in
vars|variables)
print_variables "${YADM_ARGS[@]}"
if [[ ! -z "$2" ]] ; then
shift
fi
;;
paths|path)
print_paths "${YADM_ARGS[@]}"
if [[ ! -z "$2" ]] ; then
shift
fi
;;
*)
echo "$1 is not a valid command"
;;
esac
shift
done

}

# ****** Utility Functions ******

function exclude_encrypted() {
Expand Down