aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-sm-files
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-07-08 23:36:29 +0300
committerkaotisk <kaotisk@arching-kaos.org>2024-07-08 23:36:29 +0300
commitb8d0d818b2f2a34c64dc54ce622a482d0585fcd6 (patch)
treeb4d5df850a97bb86dce61459c703f2057653caa0 /bin/ak-sm-files
parenta20d4d8e44cc4bbc66d60af4c965dfe2301864a0 (diff)
downloadarching-kaos-tools-b8d0d818b2f2a34c64dc54ce622a482d0585fcd6.tar.gz
arching-kaos-tools-b8d0d818b2f2a34c64dc54ce622a482d0585fcd6.tar.bz2
arching-kaos-tools-b8d0d818b2f2a34c64dc54ce622a482d0585fcd6.zip
Refactoring
Diffstat (limited to 'bin/ak-sm-files')
-rwxr-xr-xbin/ak-sm-files40
1 files changed, 22 insertions, 18 deletions
diff --git a/bin/ak-sm-files b/bin/ak-sm-files
index 1d69f08..317149e 100755
--- a/bin/ak-sm-files
+++ b/bin/ak-sm-files
@@ -1,4 +1,16 @@
#!/bin/bash
+## sm files
+##
+## -h, --help Prints this help message
+##
+## --add <file> Adds file to zchain as a zblock
+##
+## --index List files
+##
+## --full-index List all files
+##
+## --ls-map-files List map files
+##
ZFILESDIR="$AK_WORKDIR/files"
pwd > .pwd
CRD=$(cat .pwd)
@@ -24,21 +36,13 @@ else
_ak_log_info "$ZFILESDIR found!"
fi
-usage(){
- echo "$PROGRAM - file"
- echo " -h, --help Prints this help message"
- echo " add <file> Adds file to zchain as a zblock"
- echo " index List files"
- echo " full-index List all files"
- echo " ls-map-files List map files"
-}
-add(){
+_ak_sm_files_add(){
FILENAME="$1"
- main $FILENAME $CRD
+ _ak_sm_files_main $FILENAME $CRD
cat data | jq -M
}
-main(){
+_ak_sm_files_main(){
FILENAME="$1"
CRP="$2"
@@ -128,11 +132,11 @@ EOF
fi
}
-index(){
+_ak_sm_files_index(){
tail -n1 $AK_WORKDIR/fmp/* | grep '^[abcdef1234567890]' | awk '{ print $2 }'
}
-ls-mapfiles(){
+_ak_sm_files_ls_mapfiles(){
cd $AK_WORKDIR/fmp
for f in `find . -type f | sed -e 's/\.\///g'`;do
FILENAME="$(tail -n1 $f | grep '^[abcdef1234567890]' | awk '{ print $2 }')"
@@ -142,17 +146,17 @@ ls-mapfiles(){
done
}
-full-index(){
+_ak_sm_files_full_index(){
tail -n1 $AK_WORKDIR/fmp/* | grep '^[abcdef1234567890]'
}
if [ ! -z $1 ]; then
case $1 in
-h | --help) usage; exit;;
- add) add $2; exit;;
- index) index; exit;;
- full-index) full-index; exit;;
- ls-map-files) ls-mapfiles; exit;;
+ --add) _ak_sm_files_add $2; exit;;
+ --index) _ak_sm_files_index; exit;;
+ --full-index) _ak_sm_files_full_index; exit;;
+ --ls-map-files) _ak_sm_files_ls_mapfiles; exit;;
*) usage; exit;;
esac
else usage