mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-26 01:03:40 +00:00
Update cli and makefile
This commit is contained in:
2
Makefile
2
Makefile
@@ -166,7 +166,7 @@ test: test-release
|
|||||||
|
|
||||||
# Run bash script to output cli.txt
|
# Run bash script to output cli.txt
|
||||||
cli:
|
cli:
|
||||||
./scripts/cli.sh
|
./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
|
||||||
|
|
||||||
|
|||||||
119
scripts/cli.sh
119
scripts/cli.sh
@@ -1,5 +1,17 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
|
write_to_file() {
|
||||||
|
local cmd="$1"
|
||||||
|
local file="$2"
|
||||||
|
local program="$3"
|
||||||
|
|
||||||
|
# Remove first line of cmd to get rid of commit specific numbers.
|
||||||
|
cmd=${cmd#*$'\n'}
|
||||||
|
|
||||||
|
# We need to add the header and the backticks to create the code block.
|
||||||
|
printf "#%s\n\n\`\`\`\n%s\n\`\`\`" "$program" "$cmd" > "$file"
|
||||||
|
}
|
||||||
|
|
||||||
# Check if a lighthouse binary exists in the current branch.
|
# Check if a lighthouse binary exists in the current branch.
|
||||||
# -f means check if the file exists, to see all options, type "bash test" in a terminal
|
# -f means check if the file exists, to see all options, type "bash test" in a terminal
|
||||||
maxperf=./target/maxperf/lighthouse
|
maxperf=./target/maxperf/lighthouse
|
||||||
@@ -18,66 +30,69 @@ else
|
|||||||
CMD="$debug"
|
CMD="$debug"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the existing help text file if it exists.
|
|
||||||
rm -f -- cli.txt
|
|
||||||
|
|
||||||
# Store all help strings in variables.
|
# Store all help strings in variables.
|
||||||
general=$($CMD --help)
|
general_cli=$($CMD --help)
|
||||||
|
bn_cli=$($CMD bn --help)
|
||||||
|
vc_cli=$($CMD vc --help)
|
||||||
|
am_cli=$($CMD am --help)
|
||||||
|
|
||||||
# accoun manager
|
general=./general_help.md
|
||||||
a=$($CMD a --help)
|
bn=./bn_help.md
|
||||||
|
vc=./vc_help.md
|
||||||
|
am=./am_help.md
|
||||||
|
|
||||||
a_validator=$($CMD a validator --help)
|
# create .md files
|
||||||
a_validator_m=$($CMD a validator modify --help)
|
write_to_file "$general_cli" "$general" "Lighthouse General Commands"
|
||||||
a_validator_s=$($CMD a validator slashing-protection --help)
|
write_to_file "$bn_cli" "$bn" "Beacon Node"
|
||||||
|
write_to_file "$vc_cli" "$vc" "Validator Client"
|
||||||
|
write_to_file "$am_cli" "$am" "Account Manager"
|
||||||
|
|
||||||
a_wallet=$($CMD a wallet --help)
|
# create empty array to store variables for exit condition later
|
||||||
|
exist=()
|
||||||
# beacon node
|
update=()
|
||||||
|
for i in general_help bn_help vc_help am_help
|
||||||
bn=$($CMD bn --help)
|
do
|
||||||
|
if [[ -f ./book/src/cli/$i.md ]]; then # first check if .md exists
|
||||||
# boot-node
|
echo "$i.md exists, continue to check for any changes"
|
||||||
boot=$($CMD boot_node --help)
|
difference=$(diff ./book/src/cli/$i.md $i.md)
|
||||||
|
case1=false
|
||||||
# data manager
|
exist+=($case1)
|
||||||
dm=$($CMD db --help)
|
if [[ -z $difference ]]; then # then check if any changes required
|
||||||
|
case2=false
|
||||||
# validator client
|
update+=($case2)
|
||||||
vc=$($CMD vc --help)
|
echo "$i.md is up to date"
|
||||||
|
|
||||||
# Print all help strings to the cli.txt file.
|
|
||||||
printf "%s\n\n" "$general" "$a" "$a_validator" "$a_validator_m" "$a_validator_s" "$a_wallet" "$bn" "$boot" "$dm" "$vc" "$wallet" >> cli.txt
|
|
||||||
|
|
||||||
# Run the bash script to generate cli_manual.txt
|
|
||||||
#./cli_manual.sh
|
|
||||||
|
|
||||||
if [[ -f ./scripts/cli_manual.txt ]];
|
|
||||||
then
|
|
||||||
changes=$(diff -u ./scripts/cli_manual.txt cli.txt | tee update )
|
|
||||||
else
|
else
|
||||||
echo "cli_manual.txt is not found"
|
cp $i.md ./book/src/cli/$i.md
|
||||||
exit 1
|
echo "$i has been updated"
|
||||||
|
case2=true
|
||||||
|
update+=($case2)
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$i.md is not found, it will be created now"
|
||||||
|
cp $i.md ./book/src/cli/$i.md
|
||||||
|
case1=true
|
||||||
|
exist+=($case1)
|
||||||
|
# echo $case1
|
||||||
|
#exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# compare two files to see if there are any differences: https://www.geeksforgeeks.org/cmp-command-in-linux-with-examples/
|
# use during testing to show exit conditions
|
||||||
# compare=$(cmp cli_manual.txt cli.txt)
|
#echo "${exist[@]}"
|
||||||
|
#echo "${update[@]}"
|
||||||
|
|
||||||
# to display the changes, commented for now
|
# exit condition, exit when .md does not exist or changes requried
|
||||||
# echo $changes
|
if [[ ${exist[@]} == *"true"* && ${update[@]} == *"true"* ]]; then
|
||||||
|
echo "exit 1 due to one or more .md file does not exist and changes updated"
|
||||||
# -z checks if a file is null: https://www.cyberciti.biz/faq/bash-shell-find-out-if-a-variable-has-null-value-or-not/
|
|
||||||
if [[ -z $changes ]];
|
|
||||||
then
|
|
||||||
no_change=true
|
|
||||||
echo "cli_manual.txt is up to date"
|
|
||||||
# if the difference is empty, use true to execute nothing: https://stackoverflow.com/questions/17583578/what-command-means-do-nothing-in-a-conditional-in-bash
|
|
||||||
else
|
|
||||||
exit 1
|
exit 1
|
||||||
#patch ./scripts/cli_manual.txt update
|
elif [[ ${exist[@]} == *"true"* ]]; then
|
||||||
#echo "cli_manual.txt has been updated"
|
echo "exit 1 due to one or more .md file does not exist"
|
||||||
|
exit 1
|
||||||
|
elif [[ ${update[@]} == *"true"* ]]; then
|
||||||
|
echo "exit 1 due to changes updated"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Task completed, no changes in CLI parameters"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# update cli_manual.sh
|
# remove .md files in current directory
|
||||||
#patch cli_manual.txt patchfile.patch
|
rm -f general_help.md bn_help.md vc_help.md am_help.md
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user