From facc6b73b0cf0076418a4a63dfe2ae40a8645967 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 29 Jun 2025 20:52:40 +1200 Subject: [PATCH] feat: Update 4 files --- bb64/publish.sh | 7 +++++++ dehydrate/publish.sh | 7 +++++++ getpkg/publish.sh | 7 +++++++ getpkg/src/main.cpp | 27 +++++++++++++++++++-------- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/bb64/publish.sh b/bb64/publish.sh index 342c91c..3bf8f0e 100755 --- a/bb64/publish.sh +++ b/bb64/publish.sh @@ -20,7 +20,14 @@ echo "Building version $VERSION" >&2 # build release version export CMAKE_BUILD_TYPE="Release" +# Build with or without cache based on NO_CACHE environment variable +CACHE_FLAG="" +if [ "${NO_CACHE:-false}" = "true" ]; then + CACHE_FLAG="--no-cache" +fi + docker build \ + ${CACHE_FLAG} \ -t "${PROJECT}-build" \ -f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \ --build-arg PROJECT="${PROJECT}" \ diff --git a/dehydrate/publish.sh b/dehydrate/publish.sh index affa6f8..0ef79bc 100755 --- a/dehydrate/publish.sh +++ b/dehydrate/publish.sh @@ -36,7 +36,14 @@ heading "Building ${PROJECT}" # build release version export CMAKE_BUILD_TYPE="Release" +# Build with or without cache based on NO_CACHE environment variable +CACHE_FLAG="" +if [ "${NO_CACHE:-false}" = "true" ]; then + CACHE_FLAG="--no-cache" +fi + docker build \ + ${CACHE_FLAG} \ -t "${PROJECT}-build" \ -f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \ --build-arg PROJECT="${PROJECT}" \ diff --git a/getpkg/publish.sh b/getpkg/publish.sh index 146bcd9..3cff909 100755 --- a/getpkg/publish.sh +++ b/getpkg/publish.sh @@ -35,7 +35,14 @@ heading "Building ${PROJECT}" # build release version export CMAKE_BUILD_TYPE="Release" +# Build with or without cache based on NO_CACHE environment variable +CACHE_FLAG="" +if [ "${NO_CACHE:-false}" = "true" ]; then + CACHE_FLAG="--no-cache" +fi + docker build \ + ${CACHE_FLAG} \ -t "${PROJECT}-build" \ -f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \ --build-arg PROJECT="${PROJECT}" \ diff --git a/getpkg/src/main.cpp b/getpkg/src/main.cpp index dacddbb..f9626f4 100644 --- a/getpkg/src/main.cpp +++ b/getpkg/src/main.cpp @@ -76,6 +76,17 @@ namespace { using json = nlohmann::json; +// Clear current line and reset cursor to beginning +void clearLine() { + std::cout << "\r\033[K" << std::flush; +} + +// Clear current line and print message +void clearAndPrint(const std::string& message) { + clearLine(); + std::cout << message << std::flush; +} + // Compare versions (returns true if v1 < v2) bool isVersionOlder(const std::string& v1, const std::string& v2) { // Simple version comparison - assumes versions are in YYYY.MMDD.HHMM format @@ -215,14 +226,14 @@ int install_tool(int argc, char* argv[]) { std::cout << "Downloading " << toolName << "..." << std::flush; if (!getbin2.download(toolName, arch, archivePath.string(), progressCallback)) { // Try universal version as fallback - std::cout << "\rArch-specific version not found, trying universal..." << std::endl; + clearAndPrint("Arch-specific version not found, trying universal...\n"); if (!getbin2.download(toolName, "universal", archivePath.string(), progressCallback)) { std::cerr << "\rFailed to download tool archive (tried both " << arch << " and universal)." << std::endl; return 1; } downloadArch = "universal"; } - std::cout << "\rDownloading " << toolName << "... done" << std::endl; + clearAndPrint("Downloading " + toolName + "... done\n"); // Unpack tool std::cout << "Unpacking..." << std::flush; @@ -230,13 +241,13 @@ int install_tool(int argc, char* argv[]) { std::cerr << "\rFailed to unpack tool archive." << std::endl; return 1; } - std::cout << "\rUnpacking... done" << std::endl; + clearAndPrint("Unpacking... done\n"); // Add to PATH and autocomplete std::cout << "Configuring..." << std::flush; scriptManager.addToolEntry(toolName, binDir.string()); scriptManager.addAutocomplete(toolName); - std::cout << "\rConfiguring... done" << std::endl; + clearAndPrint("Configuring... done\n"); // Get tool info std::string hash; @@ -347,7 +358,7 @@ int publish_tool(int argc, char* argv[]) { std::cerr << "\rFailed to upload archive." << std::endl; return 1; } - std::cout << "\rUploading... done" << std::endl; + clearAndPrint("Uploading... done\n"); std::cout << "Published! URL: " << url << "\nHash: " << hash << std::endl; return 0; } @@ -426,7 +437,7 @@ int update_tool(int argc, char* argv[]) { tool.status = "Check failed"; } } - std::cout << "\r" << std::string(50, ' ') << "\r" << std::flush; // Clear progress line + clearLine(); // Clear progress line // Step 2: Update tools that need updating std::vector> updateResults; @@ -484,7 +495,7 @@ int update_tool(int argc, char* argv[]) { if (result == 0) { tool.status = "Updated"; - std::cout << " Updated" << std::endl; + clearAndPrint("Updated\n"); // Re-read version after update std::filesystem::path toolInfoPath = configDir / (tool.name + ".json"); @@ -502,7 +513,7 @@ int update_tool(int argc, char* argv[]) { } } else { tool.status = "Failed"; - std::cout << " Failed" << std::endl; + clearAndPrint("Failed\n"); } } }