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

updated sys logging functions #50

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion argparse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ else

else
# Invalid command - show error message
sys.error "Invalid command! Try again"
sys.log.error "Invalid command! Try again"
echo "Type 'wyx' to see the list of available commands (and their arguments), or 'wyx help' to be redirected to more in-depth online documentation"
fi
fi
Expand Down
44 changes: 22 additions & 22 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ setup_completion() {
# Install dependencies
sys.dependencies.install

sys.info "Setting up wyx-cli..."
sys.log.info "Setting up wyx-cli..."
chmod +x wyx-cli.sh


Expand All @@ -39,7 +39,7 @@ for i in "${files[@]}"; do
touch "$md_dir/$i"
chmod +rwx "$md_dir/$i"
else
sys.warn "File $i already exists. Would you like to overwrite it? [ y / n ]"
sys.log.warn "File $i already exists. Would you like to overwrite it? [ y / n ]"
read -r overwrite_file
if [ "$overwrite_file" = "y" ]; then
rm "$md_dir/$i"
Expand All @@ -48,32 +48,32 @@ for i in "${files[@]}"; do

echo ""
if [ "$i" = "git-user.txt" ]; then
sys.h1 "Please enter your github username:"
sys.log.h1 "Please enter your github username:"
read -r gituser
echo ""
sys.h1 "Please enter your full name (this will be used for copyright clauses on GitHub software licenses):"
sys.log.h1 "Please enter your full name (this will be used for copyright clauses on GitHub software licenses):"
read -r fullname
{ echo "username=$gituser"; echo "name=$fullname"; } >> "$md_dir/$i"
elif [ "$i" = "git-orgs.txt" ]; then
sys.h1 "Please enter the default github organization you want to setup with this cli: (enter it's github username) ***leave empty if none***"
sys.log.h1 "Please enter the default github organization you want to setup with this cli: (enter it's github username) ***leave empty if none***"
read -r gitorg
{ echo "default=$gitorg"; } >> "$md_dir/$i"
elif [ "$i" = "dir-aliases.txt" ]; then
sys.h1 "Would you like to include the default directory aliases? [ y / n ]"
sys.log.h1 "Would you like to include the default directory aliases? [ y / n ]"
read -r keep_default_diraliases
if [ "$keep_default_diraliases" = "y" ]; then
{ echo "docs=~/Documents"; echo "down=~/Downloads"; } >> "$md_dir/$i"
fi
elif [ "$i" = "run-configs.txt" ]; then
sys.info "Run configs flushed"
sys.log.info "Run configs flushed"
elif [ "$i" = ".env" ]; then
sys.info "Environment variables flushed"
sys.log.info "Environment variables flushed"
elif [ "$i" = "todo.txt" ]; then
sys.info "TODO flushed"
sys.log.info "TODO flushed"
{ echo "TODO:"; echo ""; } >> "$md_dir/$i"
fi

sys.info "$i setup complete!"
sys.log.info "$i setup complete!"
fi
echo ""
fi
Expand All @@ -87,20 +87,20 @@ fi
user_file=$(cat $md_dir/git-user.txt)
if [ "$user_file" = "" ]; then
echo ""
sys.h1 "Please enter your github username:"
sys.log.h1 "Please enter your github username:"
read -r gituser
echo "username=$gituser" >> $md_dir/git-user.txt

echo ""
sys.h1 "Please enter your full name (this will be used for copyright clauses on GitHub software licenses):"
sys.log.h1 "Please enter your full name (this will be used for copyright clauses on GitHub software licenses):"
read -r fullname
echo "name=$fullname" >> $md_dir/git-user.txt
fi

org_file=$(cat $md_dir/git-orgs.txt)
if [ "$org_file" = "" ]; then
echo ""
sys.h1 "Please enter the default github organization you want to setup with this cli: (enter it's github username) ***leave empty if none***"
sys.log.h1 "Please enter the default github organization you want to setup with this cli: (enter it's github username) ***leave empty if none***"
read -r gitorg
if [ "$gitorg" != "" ]; then
echo "default=$gitorg" >> $md_dir/git-orgs.txt
Expand All @@ -113,7 +113,7 @@ if [ "$dir_file" = "" ]; then
echo "The default directory aliases setup are as follows:"
echo "1) docs = ~/Documents"
echo "2) down = ~/Downloads"
sys.h1 "Would you like to include these? [ y / n ]"
sys.log.h1 "Would you like to include these? [ y / n ]"
read -r keep_default_diraliases
if [ "$keep_default_diraliases" = "y" ]; then
{ echo "docs=~/Documents"; echo "down=~/Downloads"; } >> $md_dir/dir-aliases.txt
Expand All @@ -122,13 +122,13 @@ fi

# FINAL SETUP
echo ""
sys.info "Okay we should be good to go!"
sys.log.info "Okay we should be good to go!"

# ADD ALIAS TO ENV FILE
envfile=$(sys.shell.envfile)
wyx_alias=$(cat "$envfile" | grep -c "alias wyx")
if [ "$wyx_alias" != "" ]; then
sys.warn "It looks like you already have a wyx alias setup. Would you like to overwrite it? [ y / n ]"
sys.log.warn "It looks like you already have a wyx alias setup. Would you like to overwrite it? [ y / n ]"
read -r overwrite_alias
if [ "$overwrite_alias" = "y" ]; then
echo "${ORANGE}Please edit the $envfile file manually to remove your old alias${RESET}"
Expand All @@ -143,7 +143,7 @@ completionfile="$HOME/.bash_completion"
if [ -f "$completionfile" ]; then
completion_search=$(cat "$completionfile" | grep -c "$(pwd)/completion.sh")
if [ "$completion_search" != "" ]; then
sys.warn "It looks like you already have wyx completion setup. Would you like to overwrite it? [ y / n ]"
sys.log.warn "It looks like you already have wyx completion setup. Would you like to overwrite it? [ y / n ]"
read -r overwrite_completion
if [ "$overwrite_completion" = "y" ]; then
echo "${ORANGE}Please edit the $HOME/.bashrc file manually to remove your old completion${RESET}"
Expand All @@ -153,18 +153,18 @@ if [ -f "$completionfile" ]; then
setup_completion
fi
else
sys.warn "It looks like you don't have a $HOME/.bash_completion file (allowing you to use the wyx command with tab-completion)."
sys.warn "Would you like to create one? [ y / n ]"
sys.log.warn "It looks like you don't have a $HOME/.bash_completion file (allowing you to use the wyx command with tab-completion)."
sys.log.warn "Would you like to create one? [ y / n ]"
read -r create_completion
if [ "$create_completion" = "y" ]; then
touch "$HOME/.bash_completion"
setup_completion
else
sys.error "You need to have a $HOME/.bash_completion file to use wyx completion, rerun this setup script if you would like to create one."
sys.log.error "You need to have a $HOME/.bash_completion file to use wyx completion, rerun this setup script if you would like to create one."
fi
fi

echo ""
sys.info "WYX CLI setup complete !"
sys.info "Use 'wyx' to get going :)"
sys.log.info "WYX CLI setup complete !"
sys.log.info "Use 'wyx' to get going :)"
echo ""
Loading