diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2022-10-25 13:32:57 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2022-10-25 13:32:57 +0300 |
commit | ec812d4606fcda595448967b04ec6ee59ecba979 (patch) | |
tree | 9b46ab5d0ebdd1dca34ec33e3db4511c07c9345f /bin | |
parent | c230f21f1a7d52418cdc025b15e5cbd669204d9f (diff) | |
download | arching-kaos-tools-ec812d4606fcda595448967b04ec6ee59ecba979.tar.gz arching-kaos-tools-ec812d4606fcda595448967b04ec6ee59ecba979.tar.bz2 arching-kaos-tools-ec812d4606fcda595448967b04ec6ee59ecba979.zip |
Adapting to 96ae225b2a179ec36fdb01eaf906fec096002a08 change
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/comments | 50 | ||||
-rwxr-xr-x | bin/pack_z_block | 11 | ||||
-rwxr-xr-x | bin/profile | 12 |
3 files changed, 31 insertions, 42 deletions
diff --git a/bin/comments b/bin/comments index bcb29ee..fc226b2 100755 --- a/bin/comments +++ b/bin/comments @@ -1,14 +1,13 @@ #!/bin/bash ZCOMMENTSDIR="$WORKDIR/comments" TEMP="/tmp/aktmp" -echo $ZCOMMENTSDIR if [ ! -d $ZCOMMENTSDIR ]; then mkdir $ZCOMMENTSDIR cd $ZCOMMENTSDIR git init - echo "zcommentsdir created along with git repo" + logthis "[INFO]" "zcommentsdir created along with git repo" else - echo "zcommentsdir found" + logthis "[INFO]" "zcommentsdir found" fi tempassin(){ if [ ! -z $1 ] @@ -27,6 +26,10 @@ create(){ if [ ! -z $1 ] then REFER_TO="$1" + else + logthis "[ERROR]" "No reference given" + echo "[ERROR]" "No reference given" + exit 1 fi tempassin $TEMP export COMMENTS_FILE="$(date -u +%s)" @@ -36,7 +39,7 @@ create(){ IPFS_FILE=$(ipfs add -q $COMMENTS_FILE) mv $COMMENTS_FILE $ZCOMMENTSDIR/$TO_FILE add $TO_FILE - echo "Adding to git repo..." + logthis "[INFO]" "Adding to git repo..." cd $ZCOMMENTSDIR git add $TO_FILE git commit -m "Added $TO_FILE with $(head -n 1 $ZCOMMENTSDIR/$TO_FILE)" @@ -59,30 +62,7 @@ index(){ done } title(){ - echo ak-comments-cli - echo "--------------" -} -import(){ - echo "#TODO" - if [ ! -z $1 ] - then - if [ ! -d $1 ] - then - echo "Folder does not exists" - exit 4 - else - echo "Folder $1 exists" - fl="$(ls -1 $1)" - for f in $fl - do - add $1/$f - done - fi - else - echo "No value" - exit 6 - fi - exit 224 + echo comments } add(){ tempassin @@ -108,7 +88,7 @@ EOF REFERENCE="$(pack_z_block "comments/add" data)" if [ $? == 0 ] then - echo "Comments added successfully" + echo "Comment added successfully" else echo "error??" exit 1 @@ -116,14 +96,13 @@ EOF } usage(){ title - echo "#TODO" echo "All you need to know is that there are two options available:" - echo "help Prints this help message" - echo "index Prints an indexed table of your comments files" - echo "import <file> #TODO" - echo "add <file> <refer_to> Creates a data file from the comments file you point to" + echo "" + echo "help Prints this help message" + echo "index Prints an indexed table of your comments files" + echo "add <file> <refer_to> Creates a data file from the comments file you point to" echo "create <refer_to> Vim is going to pop up, you will write and save your" - echo " commentsletter and it's going to be saved" + echo " commentsletter and it's going to be saved" exit 0 } @@ -131,7 +110,6 @@ if [ ! -z $1 ]; then case $1 in help) usage; exit;; index) index; exit;; - import) import $2; exit;; add) add $2 $3; exit;; create) create $2; exit;; * ) usage;; diff --git a/bin/pack_z_block b/bin/pack_z_block index b166463..158a2cd 100755 --- a/bin/pack_z_block +++ b/bin/pack_z_block @@ -14,7 +14,12 @@ # The following example finds kaos@kaos.kaos' GPG fingerprint like this # FINGERPRINT="$(gpg2 --list-keys | grep kaos@kaos.kaos -1 | head -n1 | awk '{print $1}')" -PROGRAM="pack_z_block" +PROGRAM="$(basename $0)" + +# Logging patch +logit(){ + logthis "<$PROGRAM>" "$1" "$2" +} # Below, the usage information usage(){ @@ -34,7 +39,7 @@ usage(){ main(){ - logthis "[INFO]" "We are doing" $ACTION "with content" $MESSAGE + logit "[INFO]" "We are doing" $ACTION "with content" $MESSAGE # We add it to IPFS MESSAGE_HASH=$(ipfs add -q $MESSAGE) @@ -96,7 +101,7 @@ then if [ -f "$MESSAGE" ]; then main else - logthis "[ERROR]" "File does not exist. Aborting..." + logit "[ERROR]" "File does not exist. Aborting..." exit 1 fi diff --git a/bin/profile b/bin/profile index c779ba7..4cc0827 100755 --- a/bin/profile +++ b/bin/profile @@ -1,6 +1,12 @@ #!/bin/bash +PROGRAM="$(basename $0)" ZPROFILEDIR="$WORKDIR/profile" TEMP="/tmp/aktmp" + +logit(){ + logthis "<$PROGRAM>" "$1" "$2" +} + if [ ! -d $ZPROFILEDIR ]; then mkdir $ZPROFILEDIR cd $ZPROFILEDIR @@ -9,9 +15,9 @@ if [ ! -d $ZPROFILEDIR ]; then # echo "Qmetc" >> README # git add README # git commit -m "Initiated profile repository" - logthis "[INFO]" "zprofiledir created along with git repo" + logit "[INFO]" "zprofiledir created along with git repo" else - logthis "[INFO]" "zprofiledir found" + logit "[INFO]" "zprofiledir found" fi tempassin(){ if [ ! -z $1 ] @@ -32,7 +38,7 @@ tempassin(){ show(){ if [ ! -z $1 ] then - logthis "[INFO]" "Working with $1" + logit "[INFO]" "Working with $1" echo '"data":"'$1'",' echo '"'$1'":'$(ipfs cat $1)',' #ipfs cat $1 |