:-'Generic Commit'
This commit is contained in:
parent
401280cf23
commit
8556b683c7
47
dropshell-tool/publish.sh
Executable file
47
dropshell-tool/publish.sh
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo -e "Error: $1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
MYARCH=$(uname -m)
|
||||||
|
|
||||||
|
|
||||||
|
"${SCRIPT_DIR}/build.sh" -m -r || die "Failed to build"
|
||||||
|
|
||||||
|
PUBLISH_DIR="${SCRIPT_DIR}/tool"
|
||||||
|
OUTPUT_DIR="${SCRIPT_DIR}/output"
|
||||||
|
|
||||||
|
# Find all dropshell-tool.ARCH files in output/
|
||||||
|
TOOLS=()
|
||||||
|
for tool in "${SCRIPT_DIR}/output/"/*dropshell-tool.*; do
|
||||||
|
[ -f "$tool" ] || continue
|
||||||
|
tool_name=$(basename "$tool")
|
||||||
|
TOOLS+=("$tool_name")
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ${#TOOLS[@]} -eq 0 ]; then
|
||||||
|
echo "No tools found in ${SCRIPT_DIR}/output/. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for TOOL in "${TOOLS[@]}"; do
|
||||||
|
echo "Publishing $TOOL"
|
||||||
|
|
||||||
|
# extract the architecture from the tool name
|
||||||
|
ARCH="${TOOL//dropshell-tool./}"
|
||||||
|
|
||||||
|
# copy the tool to the output/ directory
|
||||||
|
cp "$OUTPUT_DIR/$TOOL" "$PUBLISH_DIR/dropshell-tool" || die "Failed to copy $TOOL to $PUBLISH_DIR/dropshell-tool"
|
||||||
|
|
||||||
|
"$OUTPUT_DIR/dropshell-tool.${MYARCH}" publish "dropshell-tool:${ARCH}" "$PUBLISH_DIR" || die "Failed to publish $TOOL"
|
||||||
|
|
||||||
|
# remove the tool from the output/ directory
|
||||||
|
rm "$PUBLISH_DIR/dropshell-tool" || die "Failed to remove $PUBLISH_DIR/dropshell-tool"
|
||||||
|
done
|
@ -41,8 +41,8 @@
|
|||||||
dropshell-tool version
|
dropshell-tool version
|
||||||
- prints the version of dropshell-tool
|
- prints the version of dropshell-tool
|
||||||
|
|
||||||
dropshell-tool create <tool_name>
|
dropshell-tool create <tool_name> <directory_name>
|
||||||
- creates a new tool source directory in relative path <tool_name> if it doesn't exist
|
- creates a new tool source directory in relative path <directory_name> if it doesn't exist
|
||||||
- creates a dropshell-tool-config.json file in the tool source directory if it doesn't exist, with the following entries:
|
- creates a dropshell-tool-config.json file in the tool source directory if it doesn't exist, with the following entries:
|
||||||
- aliases: an array of aliases for the tool
|
- aliases: an array of aliases for the tool
|
||||||
- setup_script: the name of the setup script to run (setup_script.sh)
|
- setup_script: the name of the setup script to run (setup_script.sh)
|
||||||
@ -244,12 +244,13 @@ int update_tool(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int create_tool(int argc, char* argv[]) {
|
int create_tool(int argc, char* argv[]) {
|
||||||
if (argc < 3) {
|
if (argc < 4) {
|
||||||
std::cerr << "Usage: dropshell-tool create <tool_name>" << std::endl;
|
std::cerr << "Usage: dropshell-tool create <tool_name> <directory_name>" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::string toolName = argv[2];
|
std::string toolName = argv[2];
|
||||||
std::filesystem::path toolDir = std::filesystem::current_path() / toolName;
|
std::string directoryName = argv[3];
|
||||||
|
std::filesystem::path toolDir = std::filesystem::current_path() / directoryName;
|
||||||
if (!std::filesystem::exists(toolDir)) {
|
if (!std::filesystem::exists(toolDir)) {
|
||||||
std::filesystem::create_directories(toolDir);
|
std::filesystem::create_directories(toolDir);
|
||||||
std::cout << "Created directory: " << toolDir << std::endl;
|
std::cout << "Created directory: " << toolDir << std::endl;
|
||||||
|
4
dropshell-tool/tool/dropshell-tool-config.json
Normal file
4
dropshell-tool/tool/dropshell-tool-config.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"aliases": [],
|
||||||
|
"setup_script": "setup_script.sh"
|
||||||
|
}
|
2
dropshell-tool/tool/setup_script.sh
Executable file
2
dropshell-tool/tool/setup_script.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo 'Setup complete.'
|
Loading…
x
Reference in New Issue
Block a user