lighthouse/scripts/cli.sh

99 lines
2.9 KiB
Bash
Raw Normal View History

CLI in Lighthouse Book (#4571) * Add cli.sh file * update bash script * update Makefile * update * modified test-suite * fix path * Fix cli.sh permissions * update cmd * cli_manual * Revise to update * Update directory in Github * Correct cli.txt directory * test old cli_manual * change exit 1 * Update cli and makefile * Move cli.sh * remove files * fix permission * Indentation and revision * Fixed permission * Create new cli folder * remove dummy * put a dummy file * Revise cli.sh * comment * function * remove vm.md * test make cli * test * testing * testing * update * update * test * test * add vm * change back non-debug mode * add exist and update for future debug * revise * remove troubleshooting part * update * add summary.md * test * test * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Remove help-cli.md and rearrange * Remove help-cli.md * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * remove maxperf * move then to same line as if * Fix indent and echo file not found * To be explicit in replacing the old file * Add logging when there are changes * Add local variables * spacing * remove cargo fmt * update .md files * Edit exit message to avoid confusion * Remove am and add vm subcommands * Add cargo-fmt * Revise test-suite.yml * Update SUMMARY.md * Add set -e * Add vm * Fix * Add vm * set -e * Remove return 1 and add : * Small revision * Fix typo * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Indent * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Remove .exe in Windows * Fix period with \. * test * check diff * linux commit * Add cli.sh file * update bash script * update Makefile * update * modified test-suite * fix path * Fix cli.sh permissions * update cmd * cli_manual * Revise to update * Update directory in Github * Correct cli.txt directory * test old cli_manual * change exit 1 * Update cli and makefile * Move cli.sh * remove files * fix permission * Indentation and revision * Fixed permission * Create new cli folder * remove dummy * put a dummy file * Revise cli.sh * comment * function * remove vm.md * test make cli * test * testing * testing * update * update * test * test * add vm * change back non-debug mode * add exist and update for future debug * revise * remove troubleshooting part * update * add summary.md * test * test * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Remove help-cli.md and rearrange * Remove help-cli.md * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * remove maxperf * move then to same line as if * Fix indent and echo file not found * To be explicit in replacing the old file * Add logging when there are changes * Add local variables * spacing * remove cargo fmt * Edit exit message to avoid confusion * update .md files * Remove am and add vm subcommands * Add cargo-fmt * Revise test-suite.yml * Update SUMMARY.md * Add set -e * Add vm * Fix * Add vm * set -e * Remove return 1 and add : * Small revision * Fix typo * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Indent * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Remove .exe in Windows * Fix period with \. * test * check diff * Revert "Merge branch 'book-cli' of https://github.com/chong-he/lighthouse into book-cli" This reverts commit 314005d3f8bc0c13ecfa663ac712b1a2bae17540, reversing changes made to a007f613786221211051394fad76ee1f5d0fe0f5. * update * update * Remove echo diff * Dockerize * Remove `-ti` * take ownership inside container * fix mistake * proper escaping, restore ownership afterwards * try without taking ownership of repo * update * add diff for troubleshooting * binary * update using linux * binary * make file * remove diff * add diff * update progressive balance help text * Remove diff --------- Co-authored-by: Mac L <mjladson@pm.me> Co-authored-by: antondlr <anton@delaruelle.net>
2023-12-06 23:39:22 +00:00
#! /usr/bin/env bash
# IMPORTANT
# This script should NOT be run directly.
# Run `make cli` or `make cli-local` from the root of the repository instead.
CLI in Lighthouse Book (#4571) * Add cli.sh file * update bash script * update Makefile * update * modified test-suite * fix path * Fix cli.sh permissions * update cmd * cli_manual * Revise to update * Update directory in Github * Correct cli.txt directory * test old cli_manual * change exit 1 * Update cli and makefile * Move cli.sh * remove files * fix permission * Indentation and revision * Fixed permission * Create new cli folder * remove dummy * put a dummy file * Revise cli.sh * comment * function * remove vm.md * test make cli * test * testing * testing * update * update * test * test * add vm * change back non-debug mode * add exist and update for future debug * revise * remove troubleshooting part * update * add summary.md * test * test * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Remove help-cli.md and rearrange * Remove help-cli.md * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * remove maxperf * move then to same line as if * Fix indent and echo file not found * To be explicit in replacing the old file * Add logging when there are changes * Add local variables * spacing * remove cargo fmt * update .md files * Edit exit message to avoid confusion * Remove am and add vm subcommands * Add cargo-fmt * Revise test-suite.yml * Update SUMMARY.md * Add set -e * Add vm * Fix * Add vm * set -e * Remove return 1 and add : * Small revision * Fix typo * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Indent * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Remove .exe in Windows * Fix period with \. * test * check diff * linux commit * Add cli.sh file * update bash script * update Makefile * update * modified test-suite * fix path * Fix cli.sh permissions * update cmd * cli_manual * Revise to update * Update directory in Github * Correct cli.txt directory * test old cli_manual * change exit 1 * Update cli and makefile * Move cli.sh * remove files * fix permission * Indentation and revision * Fixed permission * Create new cli folder * remove dummy * put a dummy file * Revise cli.sh * comment * function * remove vm.md * test make cli * test * testing * testing * update * update * test * test * add vm * change back non-debug mode * add exist and update for future debug * revise * remove troubleshooting part * update * add summary.md * test * test * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Remove help-cli.md and rearrange * Remove help-cli.md * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * remove maxperf * move then to same line as if * Fix indent and echo file not found * To be explicit in replacing the old file * Add logging when there are changes * Add local variables * spacing * remove cargo fmt * Edit exit message to avoid confusion * update .md files * Remove am and add vm subcommands * Add cargo-fmt * Revise test-suite.yml * Update SUMMARY.md * Add set -e * Add vm * Fix * Add vm * set -e * Remove return 1 and add : * Small revision * Fix typo * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Indent * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Remove .exe in Windows * Fix period with \. * test * check diff * Revert "Merge branch 'book-cli' of https://github.com/chong-he/lighthouse into book-cli" This reverts commit 314005d3f8bc0c13ecfa663ac712b1a2bae17540, reversing changes made to a007f613786221211051394fad76ee1f5d0fe0f5. * update * update * Remove echo diff * Dockerize * Remove `-ti` * take ownership inside container * fix mistake * proper escaping, restore ownership afterwards * try without taking ownership of repo * update * add diff for troubleshooting * binary * update using linux * binary * make file * remove diff * add diff * update progressive balance help text * Remove diff --------- Co-authored-by: Mac L <mjladson@pm.me> Co-authored-by: antondlr <anton@delaruelle.net>
2023-12-06 23:39:22 +00:00
set -e
# A function to generate formatted .md files
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"
}
CMD=./target/release/lighthouse
# Store all help strings in variables.
general_cli=$($CMD --help)
bn_cli=$($CMD bn --help)
vc_cli=$($CMD vc --help)
vm_cli=$($CMD vm --help)
vm_cli_create=$($CMD vm create --help)
vm_cli_import=$($CMD vm import --help)
vm_cli_move=$($CMD vm move --help)
general=./help_general.md
bn=./help_bn.md
vc=./help_vc.md
am=./help_am.md
vm=./help_vm.md
vm_create=./help_vm_create.md
vm_import=./help_vm_import.md
vm_move=./help_vm_move.md
# create .md files
write_to_file "$general_cli" "$general" "Lighthouse General Commands"
write_to_file "$bn_cli" "$bn" "Beacon Node"
write_to_file "$vc_cli" "$vc" "Validator Client"
write_to_file "$vm_cli" "$vm" "Validator Manager"
write_to_file "$vm_cli_create" "$vm_create" "Validator Manager Create"
write_to_file "$vm_cli_import" "$vm_import" "Validator Manager Import"
write_to_file "$vm_cli_move" "$vm_move" "Validator Manager Move"
#input 1 = $1 = files; input 2 = $2 = new files
files=(./book/src/help_general.md ./book/src/help_bn.md ./book/src/help_vc.md ./book/src/help_vm.md ./book/src/help_vm_create.md ./book/src/help_vm_import.md ./book/src/help_vm_move.md)
new_files=($general $bn $vc $vm $vm_create $vm_import $vm_move)
# function to check
check() {
local file="$1"
local new_file="$2"
if [[ -f $file ]]; then # check for existence of file
diff=$(diff $file $new_file || :)
else
cp $new_file $file
changes=true
echo "$file is not found, it has just been created"
fi
if [[ -z $diff ]]; then # check for difference
: # do nothing
else
cp $new_file $file
changes=true
echo "$file has been updated"
fi
}
# define changes as false
changes=false
# call check function to check for each help file
check ${files[0]} ${new_files[0]}
check ${files[1]} ${new_files[1]}
check ${files[2]} ${new_files[2]}
check ${files[3]} ${new_files[3]}
check ${files[4]} ${new_files[4]}
check ${files[5]} ${new_files[5]}
check ${files[6]} ${new_files[6]}
# remove help files
rm -f help_general.md help_bn.md help_vc.md help_am.md help_vm.md help_vm_create.md help_vm_import.md help_vm_move.md
# only exit at the very end
if [[ $changes == true ]]; then
echo "Exiting with error to indicate changes occurred. To fix, run `make cli-local` or `make cli` and commit the changes."
CLI in Lighthouse Book (#4571) * Add cli.sh file * update bash script * update Makefile * update * modified test-suite * fix path * Fix cli.sh permissions * update cmd * cli_manual * Revise to update * Update directory in Github * Correct cli.txt directory * test old cli_manual * change exit 1 * Update cli and makefile * Move cli.sh * remove files * fix permission * Indentation and revision * Fixed permission * Create new cli folder * remove dummy * put a dummy file * Revise cli.sh * comment * function * remove vm.md * test make cli * test * testing * testing * update * update * test * test * add vm * change back non-debug mode * add exist and update for future debug * revise * remove troubleshooting part * update * add summary.md * test * test * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Remove help-cli.md and rearrange * Remove help-cli.md * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * remove maxperf * move then to same line as if * Fix indent and echo file not found * To be explicit in replacing the old file * Add logging when there are changes * Add local variables * spacing * remove cargo fmt * update .md files * Edit exit message to avoid confusion * Remove am and add vm subcommands * Add cargo-fmt * Revise test-suite.yml * Update SUMMARY.md * Add set -e * Add vm * Fix * Add vm * set -e * Remove return 1 and add : * Small revision * Fix typo * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Indent * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Remove .exe in Windows * Fix period with \. * test * check diff * linux commit * Add cli.sh file * update bash script * update Makefile * update * modified test-suite * fix path * Fix cli.sh permissions * update cmd * cli_manual * Revise to update * Update directory in Github * Correct cli.txt directory * test old cli_manual * change exit 1 * Update cli and makefile * Move cli.sh * remove files * fix permission * Indentation and revision * Fixed permission * Create new cli folder * remove dummy * put a dummy file * Revise cli.sh * comment * function * remove vm.md * test make cli * test * testing * testing * update * update * test * test * add vm * change back non-debug mode * add exist and update for future debug * revise * remove troubleshooting part * update * add summary.md * test * test * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Update Makefile Co-authored-by: Mac L <mjladson@pm.me> * Remove help-cli.md and rearrange * Remove help-cli.md * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * remove maxperf * move then to same line as if * Fix indent and echo file not found * To be explicit in replacing the old file * Add logging when there are changes * Add local variables * spacing * remove cargo fmt * Edit exit message to avoid confusion * update .md files * Remove am and add vm subcommands * Add cargo-fmt * Revise test-suite.yml * Update SUMMARY.md * Add set -e * Add vm * Fix * Add vm * set -e * Remove return 1 and add : * Small revision * Fix typo * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Indent * Update scripts/cli.sh Co-authored-by: Mac L <mjladson@pm.me> * Remove .exe in Windows * Fix period with \. * test * check diff * Revert "Merge branch 'book-cli' of https://github.com/chong-he/lighthouse into book-cli" This reverts commit 314005d3f8bc0c13ecfa663ac712b1a2bae17540, reversing changes made to a007f613786221211051394fad76ee1f5d0fe0f5. * update * update * Remove echo diff * Dockerize * Remove `-ti` * take ownership inside container * fix mistake * proper escaping, restore ownership afterwards * try without taking ownership of repo * update * add diff for troubleshooting * binary * update using linux * binary * make file * remove diff * add diff * update progressive balance help text * Remove diff --------- Co-authored-by: Mac L <mjladson@pm.me> Co-authored-by: antondlr <anton@delaruelle.net>
2023-12-06 23:39:22 +00:00
exit 1
else
echo "CLI help texts are up to date."
exit 0
fi