Indentation and revision

This commit is contained in:
chonghe
2023-09-06 11:28:59 +08:00
parent 99c0049ca5
commit fb6f3537bb
2 changed files with 39 additions and 34 deletions

View File

@@ -166,7 +166,7 @@ test: test-release
# Run bash script to output cli.txt # Run bash script to output cli.txt
cli: cli:
./cli.sh ./scripts/cli.sh
# Runs the entire test suite, downloading test vectors if required. # Runs the entire test suite, downloading test vectors if required.
test-full: cargo-fmt test-release test-debug test-ef test-exec-engine test-full: cargo-fmt test-release test-debug test-ef test-exec-engine

71
cli.sh → scripts/cli.sh Executable file → Normal file
View File

@@ -1,5 +1,6 @@
#! /bin/bash #! /bin/bash
# A function to generate formatted .md files
write_to_file() { write_to_file() {
local cmd="$1" local cmd="$1"
local file="$2" local file="$2"
@@ -52,46 +53,50 @@ exist=()
update=() update=()
for i in general_help bn_help vc_help am_help for i in general_help bn_help vc_help am_help
do do
if [[ -f ./book/src/cli/$i.md ]]; then # first check if .md exists if [[ -f ./book/src/cli/$i.md ]]; # first check if .md exists
echo "$i.md exists, continue to check for any changes" then
difference=$(diff ./book/src/cli/$i.md $i.md) echo "$i.md exists, continue to check for any changes"
case1=false difference=$(diff ./book/src/cli/$i.md $i.md)
exist+=($case1) case1=false
if [[ -z $difference ]]; then # then check if any changes required exist+=($case1)
case2=false if [[ -z $difference ]]; # then check if any changes required
update+=($case2) then
echo "$i.md is up to date" case2=false
else update+=($case2)
cp $i.md ./book/src/cli/$i.md echo "$i.md is up to date"
echo "$i has been updated" else
case2=true cp $i.md ./book/src/cli/$i.md
update+=($case2) echo "$i has been updated"
fi case2=true
else update+=($case2)
echo "$i.md is not found, it will be created now" fi
cp $i.md ./book/src/cli/$i.md else
case1=true echo "$i.md is not found, it will be created now"
exist+=($case1) cp $i.md ./book/src/cli/$i.md
# echo $case1 case1=true
#exit 1 exist+=($case1)
fi fi
done
# use during testing to show exit conditions # use during testing to show exit conditions
#echo "${exist[@]}" #echo "${exist[@]}"
#echo "${update[@]}" #echo "${update[@]}"
# exit condition, exit when .md does not exist or changes requried # exit condition, exit when .md does not exist or changes requried
if [[ ${exist[@]} == *"true"* && ${update[@]} == *"true"* ]]; then if [[ ${exist[@]} == *"true"* && ${update[@]} == *"true"* ]];
echo "exit 1 due to one or more .md file does not exist and changes updated" then
exit 1 echo "exit 1 due to one or more .md file does not exist and changes updated"
elif [[ ${exist[@]} == *"true"* ]]; then exit 1
echo "exit 1 due to one or more .md file does not exist" elif [[ ${exist[@]} == *"true"* ]];
exit 1 then
elif [[ ${update[@]} == *"true"* ]]; then echo "exit 1 due to one or more .md file does not exist"
echo "exit 1 due to changes updated" exit 1
exit 1 elif [[ ${update[@]} == *"true"* ]];
then
echo "exit 1 due to changes updated"
exit 1
else else
echo "Task completed, no changes in CLI parameters" echo "Task completed, no changes in CLI parameters"
fi fi
# remove .md files in current directory # remove .md files in current directory