From 8556b683c79ca47e5691bbb6ca14faeb9070fedb Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 28 May 2025 21:21:23 +1200 Subject: [PATCH] :-'Generic Commit' --- dropshell-tool/publish.sh | 47 +++++++++++++++++++ dropshell-tool/src/main.cpp | 11 +++-- .../tool/dropshell-tool-config.json | 4 ++ dropshell-tool/tool/setup_script.sh | 2 + 4 files changed, 59 insertions(+), 5 deletions(-) create mode 100755 dropshell-tool/publish.sh create mode 100644 dropshell-tool/tool/dropshell-tool-config.json create mode 100755 dropshell-tool/tool/setup_script.sh diff --git a/dropshell-tool/publish.sh b/dropshell-tool/publish.sh new file mode 100755 index 0000000..4fc38aa --- /dev/null +++ b/dropshell-tool/publish.sh @@ -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 diff --git a/dropshell-tool/src/main.cpp b/dropshell-tool/src/main.cpp index 351b6e3..e96a212 100644 --- a/dropshell-tool/src/main.cpp +++ b/dropshell-tool/src/main.cpp @@ -41,8 +41,8 @@ dropshell-tool version - prints the version of dropshell-tool - dropshell-tool create - - creates a new tool source directory in relative path if it doesn't exist + dropshell-tool create + - creates a new tool source directory in relative path 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: - aliases: an array of aliases for the tool - 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[]) { - if (argc < 3) { - std::cerr << "Usage: dropshell-tool create " << std::endl; + if (argc < 4) { + std::cerr << "Usage: dropshell-tool create " << std::endl; return 1; } 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)) { std::filesystem::create_directories(toolDir); std::cout << "Created directory: " << toolDir << std::endl; diff --git a/dropshell-tool/tool/dropshell-tool-config.json b/dropshell-tool/tool/dropshell-tool-config.json new file mode 100644 index 0000000..2a229f7 --- /dev/null +++ b/dropshell-tool/tool/dropshell-tool-config.json @@ -0,0 +1,4 @@ +{ + "aliases": [], + "setup_script": "setup_script.sh" +} \ No newline at end of file diff --git a/dropshell-tool/tool/setup_script.sh b/dropshell-tool/tool/setup_script.sh new file mode 100755 index 0000000..5838800 --- /dev/null +++ b/dropshell-tool/tool/setup_script.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo 'Setup complete.'