create logprintn function

This commit is contained in:
ark-lamp-umbrella 2024-04-12 19:44:34 -07:00
parent 58fbd77df7
commit 5206cd40cc
Signed by: ark-lamp-umbrella
GPG Key ID: 15E48F7B97025652
2 changed files with 13 additions and 8 deletions

View File

@ -2,21 +2,21 @@
source scripts/shared.fish
logprint "INFO" "blue" "creating directory $(pwd)/temp"
logprintn "INFO" "blue" "creating directory $(pwd)/temp"
mkdir -p "temp"
set dircontent $(find "." -type f | grep -v ".git" | grep -v ".temp" | sort -z)
for i in $dircontent
if [ $i != "" ]
logprint "INFO" "blue" "hashing file $i"
logprintn "INFO" "blue" "hashing file $i"
set ihash "$(sha1sum $i)"
echo "$ihash" >> "temp/directorylisthashed.txt"
end
end
if fish_is_root_user
logprint "EXIT" "red" "running as root is not supported"
logprintn "EXIT" "red" "running as root is not supported"
exit 0
else
set hash1 "$(cat temp/directorylisthashed.txt)"
@ -24,7 +24,7 @@ else
if [ "$hash1" != "$hash2" ]
read -sP "[INPUT] Root password: " rpass
if [ "$rpass" = "" ]
logprint "WARN" "yellow" "empty root password"
logprintn "WARN" "yellow" "empty root password"
exit 0
end
echo "$rpass" | sudo -S cp -r "nixos/" "/etc/"
@ -44,11 +44,11 @@ else
set gitpush "$(string lower $gitpush)"
if [ "$gitpush" = "y" ]
read -P "[INPUT] Commit message: " cmessage
logprint "INFO" "blue" "adding changes to git repo"
logprintn "INFO" "blue" "adding changes to git repo"
git add .
logprint "INFO" "blue" "creating commit with message \"$cmessage\""
logprintn "INFO" "blue" "creating commit with message \"$cmessage\""
git commit -m "$cmessage"
logprint "INFO" "blue" "pushing to external repository"
logprintn "INFO" "blue" "pushing to external repository"
git push -q
end
end

View File

@ -9,5 +9,10 @@ function logprint
set logcolorcode $(string replace "_" $(cat "./scripts/resources/ansicolorsmap.txt"| grep "$argv[2]" | string replace "$argv[2] " "") "\x1b[_m")
set logmessage "$argv[3]"
printf "[$logcolorcode$logclass\x1b[0m] $logmessage\n"
printf "[$logcolorcode$logclass\x1b[0m] $logmessage"
end
function logprintn
logprint $argv
printf "\n"
end