mirror of
https://github.com/TheLocehiliosan/yadm
synced 2024-10-27 20:34:27 +00:00
adding better variable detection
This commit is contained in:
parent
7b76dabe7b
commit
cee2b5753c
80
yadm
80
yadm
@ -99,7 +99,7 @@ function main() {
|
|||||||
|
|
||||||
# parse command line arguments
|
# parse command line arguments
|
||||||
local retval=0
|
local retval=0
|
||||||
internal_commands="^(alt|bootstrap|clean|clone|config|decrypt|encrypt|enter|git-crypt|help|--help|init|introspect|list|perms|transcrypt|upgrade|version|verify|--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
|
if [ -z "$*" ] ; then
|
||||||
# no argumnts will result in help()
|
# no argumnts will result in help()
|
||||||
help
|
help
|
||||||
@ -110,6 +110,8 @@ function main() {
|
|||||||
YADM_ARGS=()
|
YADM_ARGS=()
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# commands listed below do not process any of the parameters
|
# commands listed below do not process any of the parameters
|
||||||
if [[ "$YADM_COMMAND" =~ ^(enter|git_crypt)$ ]] ; then
|
if [[ "$YADM_COMMAND" =~ ^(enter|git_crypt)$ ]] ; then
|
||||||
YADM_ARGS=("$@")
|
YADM_ARGS=("$@")
|
||||||
@ -144,7 +146,11 @@ function main() {
|
|||||||
[ ! -d "$YADM_WORK" ] && error_out "Work tree does not exist: [$YADM_WORK]"
|
[ ! -d "$YADM_WORK" ] && error_out "Work tree does not exist: [$YADM_WORK]"
|
||||||
HOOK_COMMAND="$YADM_COMMAND"
|
HOOK_COMMAND="$YADM_COMMAND"
|
||||||
invoke_hook "pre"
|
invoke_hook "pre"
|
||||||
|
if [[ "$YADM_COMMAND" =~ ^(echo)$ ]]; then
|
||||||
|
yecho "${YADM_ARGS[@]}"
|
||||||
|
else
|
||||||
$YADM_COMMAND "${YADM_ARGS[@]}"
|
$YADM_COMMAND "${YADM_ARGS[@]}"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# any other commands are simply passed through to git
|
# any other commands are simply passed through to git
|
||||||
HOOK_COMMAND="$1"
|
HOOK_COMMAND="$1"
|
||||||
@ -1117,6 +1123,7 @@ Commands:
|
|||||||
yadm enter [COMMAND] - Run sub-shell with GIT variables set
|
yadm enter [COMMAND] - Run sub-shell with GIT variables set
|
||||||
yadm git-crypt [OPTIONS] - Run git-crypt commands for the yadm repo
|
yadm git-crypt [OPTIONS] - Run git-crypt commands for the yadm repo
|
||||||
yadm transcrypt [OPTIONS] - Run transcrypt 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:
|
Files:
|
||||||
\$HOME/.config/yadm/config - yadm's configuration file
|
\$HOME/.config/yadm/config - yadm's configuration file
|
||||||
@ -1400,8 +1407,7 @@ function version() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function verify() {
|
function print_variables(){
|
||||||
#verify internal yadm variables
|
|
||||||
local local_class
|
local local_class
|
||||||
local local_system
|
local local_system
|
||||||
local local_host
|
local local_host
|
||||||
@ -1409,25 +1415,67 @@ function verify() {
|
|||||||
local local_distro
|
local local_distro
|
||||||
set_local_alt_values
|
set_local_alt_values
|
||||||
|
|
||||||
while [[ $# -gt 0 ]] ; do
|
echo "Yadm variables:
|
||||||
case "$1" in
|
distro=$local_distro
|
||||||
-o|--os)
|
system=$local_system
|
||||||
echo "$local_system"
|
hostname=$local_host
|
||||||
|
user=$local_user
|
||||||
|
class=$local_class
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_paths(){
|
||||||
|
echo "${2}"
|
||||||
|
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
|
||||||
;;
|
;;
|
||||||
-d|--distro)
|
dir|yadm_dir)
|
||||||
echo "$local_distro"
|
echo $YADM_DIR
|
||||||
;;
|
;;
|
||||||
-u|--user)
|
config)
|
||||||
echo "$local_user"
|
echo $YADM_CONFIG
|
||||||
;;
|
;;
|
||||||
-h|--host)
|
encrypt)
|
||||||
echo "$local_host"
|
echo $YADM_ENCRYPT
|
||||||
;;
|
;;
|
||||||
-c|--class)
|
archive)
|
||||||
echo "$local_class"
|
echo $YADM_ARCHIVE
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
#do nothing.
|
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
|
||||||
|
echo "$1"
|
||||||
|
case "$1" in
|
||||||
|
vars|variables)
|
||||||
|
print_variables "${YADM_ARGS[@]}"
|
||||||
|
;;
|
||||||
|
paths|path)
|
||||||
|
print_paths "${YADM_ARGS[@]}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$1 is not a valid command"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
|
Loading…
Reference in New Issue
Block a user