diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 564a845..9332000 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -7,8 +7,8 @@ "cStandard": "c17", "cppStandard": "c++23", "includePath": [ - "${workspaceFolder}/dropshell-tool/src", - "${workspaceFolder}/dropshell-tool/src/autogen" + "${workspaceFolder}/getpkg/src", + "${workspaceFolder}/getpkg/src/autogen" ] // ... other settings ... } diff --git a/CLAUDE.md b/CLAUDE.md index b327ce9..4cf7601 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,13 +4,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Project Overview -This repository contains Dropshell Tools - a collection of utilities that support dropshell development. The main tool is `dropshell-tool`, a C++ command-line application that manages tool installation, updates, and publishing for the dropshell ecosystem. +This repository contains Dropshell Tools - a collection of utilities that support dropshell development. The main tool is `getpkg`, a C++ command-line application that manages tool installation, updates, and publishing for the dropshell ecosystem. ## Architecture ### Core Components -- **dropshell-tool**: Main C++ application (`dropshell-tool/src/`) +- **getpkg**: Main C++ application (`getpkg/src/`) - `main.cpp`: CLI interface and command routing - `ArchiveManager`: Handles .tgz archive creation/extraction - `BashrcEditor`: Manages ~/.bashrc_dropshell_tool script modifications @@ -34,14 +34,14 @@ This repository contains Dropshell Tools - a collection of utilities that suppor # Build all tools (includes install from getbin.xyz) ./buildtestpublish_all.sh -# Build specific tool (dropshell-tool) -cd dropshell-tool && ./build.sh +# Build specific tool (getpkg) +cd getpkg && ./build.sh # Test specific tool -cd dropshell-tool && ./test.sh +cd getpkg && ./test.sh # Publish specific tool (requires SOS_WRITE_TOKEN) -cd dropshell-tool && ./publish.sh +cd getpkg && ./publish.sh ``` ### Development Workflow @@ -58,13 +58,13 @@ export CMAKE_BUILD_TYPE="Release" ## Tool Functionality -dropshell-tool manages a tool ecosystem by: -- Installing tools to `~/.local/bin/dropshell-tool//` +getpkg manages a tool ecosystem by: +- Installing tools to `~/.local/bin/getpkg//` - Managing bash completions and aliases via `~/.bashrc_dropshell_tool` -- Storing tool metadata in `~/.config/dropshell-tool/` +- Storing tool metadata in `~/.config/getpkg/` - Publishing/downloading tools via getbin.xyz object storage -Each tool includes a `dropshell-tool-config.json` with aliases and setup scripts. +Each tool includes a `getpkg-config.json` with aliases and setup scripts. ## Publishing Requirements diff --git a/README.md b/README.md index 98935af..0404537 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@ Tools to support dropshell development and (behind the scenes) use. -Tools are installed to ~/.local/bin/dropshell-tool, and the tool name is added to the bash PATH, with autocomplete. +Tools are installed to ~/.local/bin/getpkg, and the tool name is added to the bash PATH, with autocomplete. ## Use -Just use dropshell-tool. You can install with: +Just use getpkg. You can install with: ``` -curl https://getbin.xyz/dropshell-tool-install | bash +curl https://getbin.xyz/getpkg-install | bash ``` diff --git a/getpkg/build.sh b/getpkg/build.sh index c4959bb..5215b27 100755 --- a/getpkg/build.sh +++ b/getpkg/build.sh @@ -10,7 +10,7 @@ export CMAKE_BUILD_TYPE="Debug" rm -rf "${SCRIPT_DIR}/output" mkdir -p "${SCRIPT_DIR}/output" -PROJECT="dropshell-tool" +PROJECT="getpkg" docker build \ -t "${PROJECT}-build" \ diff --git a/getpkg/install.sh b/getpkg/install.sh index 12df676..89089d4 100755 --- a/getpkg/install.sh +++ b/getpkg/install.sh @@ -2,18 +2,20 @@ set -euo pipefail -#SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +PROJECT="getpkg" -echo "Installing dropshell-tool" +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +echo "Installing $PROJECT" ARCH=$(uname -m) -wget "https://getbin.xyz/dropshell-tool:latest-${ARCH}" -O bootstrap && chmod a+x bootstrap +wget "https://getbin.xyz/${PROJECT}:latest-${ARCH}" -O bootstrap && chmod a+x bootstrap -./bootstrap install dropshell-tool +./bootstrap install $PROJECT rm ./bootstrap -VERSION=$(dropshell-tool version) +VERSION=$(getpkg version) echo "Dropshell tool $VERSION installed" diff --git a/getpkg/publish.sh b/getpkg/publish.sh index f10dc80..e53cc87 100755 --- a/getpkg/publish.sh +++ b/getpkg/publish.sh @@ -5,6 +5,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" ARCH=$(uname -m) TEMP_DIR="${SCRIPT_DIR}/temp" SOS="${TEMP_DIR}/sos" +PROJECT="getpkg" echo "Publishing ${PROJECT} to gitea.jde.nz/public/${PROJECT}:latest" @@ -21,7 +22,6 @@ mkdir -p "${SCRIPT_DIR}/output" # build release version export CMAKE_BUILD_TYPE="Release" -export PROJECT="dropshell-tool" docker build \ -t "${PROJECT}-build" \ @@ -31,7 +31,7 @@ docker build \ --output "${SCRIPT_DIR}/output" \ "${SCRIPT_DIR}" -[ -f ${SCRIPT_DIR}/output/dropshell-tool ] || die "Build failed." +[ -f ${SCRIPT_DIR}/output/${PROJECT} ] || die "Build failed." # download the sos binary mkdir -p "${TEMP_DIR}" diff --git a/getpkg/src/ArchiveManager.cpp b/getpkg/src/ArchiveManager.cpp index 5e2c5b0..9141908 100644 --- a/getpkg/src/ArchiveManager.cpp +++ b/getpkg/src/ArchiveManager.cpp @@ -32,7 +32,7 @@ bool ArchiveManager::unpack(const std::string& archivePath, const std::string& o bool ArchiveManager::readConfigJson(const std::string& archivePath, std::string& outJson) { // Extract config json to stdout std::ostringstream cmd; - cmd << "tar -xOzf '" << archivePath << "' dropshell-tool-config.json"; + cmd << "tar -xOzf '" << archivePath << "' getpkg-config.json"; FILE* pipe = popen(cmd.str().c_str(), "r"); if (!pipe) return false; char buffer[4096]; @@ -55,7 +55,7 @@ bool ArchiveManager::writeConfigJson(const std::string& archivePath, const std:: extractCmd << "tar -xzf '" << archivePath << "' -C '" << tmpDir << "'"; if (std::system(extractCmd.str().c_str()) != 0) return false; // 2. Write new config json - std::ofstream ofs(tmpDir + "/dropshell-tool-config.json", std::ios::binary); + std::ofstream ofs(tmpDir + "/getpkg-config.json", std::ios::binary); if (!ofs) return false; ofs << json; ofs.close(); diff --git a/getpkg/src/DropshellScriptManager.cpp b/getpkg/src/DropshellScriptManager.cpp index 181c9ae..6267012 100644 --- a/getpkg/src/DropshellScriptManager.cpp +++ b/getpkg/src/DropshellScriptManager.cpp @@ -24,7 +24,7 @@ void DropshellScriptManager::ensureExists() const { if (!std::filesystem::exists(dropshelltool::DROPSHELL_RC_PATH)) { std::filesystem::create_directories(dropshelltool::DROPSHELL_RC_PATH.parent_path()); std::ofstream outfile(dropshelltool::DROPSHELL_RC_PATH, std::ios::trunc); - outfile << "# This file is managed by dropshell-tool. Do not edit manually!" << std::endl; + outfile << "# This file is managed by getpkg. Do not edit manually!" << std::endl; outfile.close(); } } @@ -34,10 +34,10 @@ void DropshellScriptManager::addToolEntry(const std::string& toolName, const std std::ifstream infile(dropshelltool::DROPSHELL_RC_PATH); std::vector lines; std::string line; - std::string exportLine = "export PATH=\"" + toolDir + ":$PATH\" # dropshell-tool:" + toolName; + std::string exportLine = "export PATH=\"" + toolDir + ":$PATH\" # getpkg:" + toolName; bool found = false; while (std::getline(infile, line)) { - if (line.find("# dropshell-tool:" + toolName) != std::string::npos) { + if (line.find("# getpkg:" + toolName) != std::string::npos) { found = true; lines.push_back(exportLine); } else { @@ -57,7 +57,7 @@ void DropshellScriptManager::removeToolEntry(const std::string& toolName) { std::vector lines; std::string line; while (std::getline(infile, line)) { - if (line.find("# dropshell-tool:" + toolName) == std::string::npos) { + if (line.find("# getpkg:" + toolName) == std::string::npos) { lines.push_back(line); } } diff --git a/getpkg/src/main.cpp b/getpkg/src/main.cpp index 980f3e3..0dd56b2 100644 --- a/getpkg/src/main.cpp +++ b/getpkg/src/main.cpp @@ -1,54 +1,54 @@ /* - dropshell-tool + getpkg - dropshell-tool install - - confirms dropshell-tool is fully initialised: - - adds a line to the user's .bashrc file to source the dropshell-tool ~/.bashrc_dropshell_tool script, if it doesn't exist + getpkg + - confirms getpkg is fully initialised: + - adds a line to the user's .bashrc file to source the getpkg ~/.bashrc_dropshell_tool script, if it doesn't exist - creates an empty ~/.bashrc_dropshell_tool script if it doesn't exist - - creates the ~/.config/dropshell-tool directory, if it does not exist - - creates the ~/.local/bin/dropshell-tool directory, if it does not exist + - creates the ~/.config/getpkg directory, if it does not exist + - creates the ~/.local/bin/getpkg directory, if it does not exist - removes the tool from the user's system if it is already installed, and the tool's entries in the ~/.bashrc_dropshell_tool script - - downloads the tool archive (tgz) from tools.dropshell.app (tool_name:ARCH), where ARCH is the architecture of the user's system, and unpacks it to the new tool directory: ~/.local/bin/dropshell-tool// + - downloads the tool archive (tgz) from tools.dropshell.app (tool_name:ARCH), where ARCH is the architecture of the user's system, and unpacks it to the new tool directory: ~/.local/bin/getpkg// - sets the PATH to include the tool directory, by modifying the ~/.bashrc_dropshell_tool script - adds an entry for autocompletion for the tool to the ~/.bashrc_dropshell_tool script, where autocomplete just runs autocomplete - - creates a ~/.config/dropshell-tool/tool_name.json file, which contains the tool's name, version (by running version), hash from tools.dropshell.app, and architecture - - reads the json file from the tgz called dropshell-tool-config.json: + - creates a ~/.config/getpkg/tool_name.json file, which contains the tool's name, version (by running version), hash from tools.dropshell.app, and architecture + - reads the json file from the tgz called getpkg-config.json: - for each alias in the aliases array: - check if another command is using the alias, and continue only if not - check that the alias is not already in the ~/.bashrc_dropshell_tool script and continue only if not - add an entry to the ~/.bashrc_dropshell_tool script to run the tool via the alias - if the json file has a setup_script entry, run the script named in the entry in the tool directory - using sudo if the entry has sudo set to true. - dropshell-tool publish - - checks that dropshell-tool-config.json exists in the folder, and is valid (see above) + getpkg publish + - checks that getpkg-config.json exists in the folder, and is valid (see above) - creates a tgz archive of the folder, and uploads it to tools.dropshell.app, a simple object server. - prints the URL and hash of the uploaded archive - uses the token from env variable SOS_WRITE_TOKEN to write to tools.dropshell.app - dropshell-tool update - - compares the hash from the ~/.config/dropshell-tool/tool_name.json file with the hash from tools.dropshell.app (tool_name:ARCH), and continues only if they are different - - checks the version from the ~/.config/dropshell-tool/tool_name.json file with the version from tools.dropshell.app (tool_name:ARCH), and continues only if the remote version is newer (installed is older) + getpkg update + - compares the hash from the ~/.config/getpkg/tool_name.json file with the hash from tools.dropshell.app (tool_name:ARCH), and continues only if they are different + - checks the version from the ~/.config/getpkg/tool_name.json file with the version from tools.dropshell.app (tool_name:ARCH), and continues only if the remote version is newer (installed is older) - installs the tool as per the install command - dropshell-tool update all + getpkg update all - runs update on all installed tools - dropshell-tool autocomplete - - shows autocomplete for dropshell-tool, and then exits + getpkg autocomplete + - shows autocomplete for getpkg, and then exits - the tool list to choose from when calling install is hard coded in the autocomplete function - dropshell-tool version - - prints the version of dropshell-tool + getpkg version + - prints the version of getpkg - dropshell-tool create + getpkg 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: + - creates a getpkg-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) - creates a setup_script.sh file in the tool source directory if it doesn't exist, that just prints a completion message and exits - dropshell-tool help + getpkg help - shows this help message @@ -85,14 +85,14 @@ std::string get_home() { int install_tool(int argc, char* argv[]) { if (argc < 3) { - std::cerr << "Usage: dropshell-tool install " << std::endl; + std::cerr << "Usage: getpkg install " << std::endl; return 1; } std::string toolName = argv[2]; std::string arch = get_arch(); std::string home = get_home(); - std::filesystem::path configDir = std::filesystem::path(home) / ".config/dropshell-tool"; - std::filesystem::path binDir = std::filesystem::path(home) / ".local/bin/dropshell-tool" / toolName; + std::filesystem::path configDir = std::filesystem::path(home) / ".config/getpkg"; + std::filesystem::path binDir = std::filesystem::path(home) / ".local/bin/getpkg" / toolName; std::filesystem::path archivePath = configDir / (toolName + ".tgz"); std::filesystem::create_directories(configDir); std::filesystem::create_directories(binDir); @@ -153,7 +153,7 @@ int install_tool(int argc, char* argv[]) { std::system(cmd.c_str()); } } catch (...) { - std::cerr << "Warning: failed to parse dropshell-tool-config.json" << std::endl; + std::cerr << "Warning: failed to parse getpkg-config.json" << std::endl; } } std::cout << "Installed " << toolName << " successfully." << std::endl; @@ -162,15 +162,15 @@ int install_tool(int argc, char* argv[]) { int publish_tool(int argc, char* argv[]) { if (argc < 4) { - std::cerr << "Usage: dropshell-tool publish " << std::endl; + std::cerr << "Usage: getpkg publish " << std::endl; return 1; } std::string labeltag = argv[2]; std::string folder = argv[3]; std::string home = get_home(); - std::filesystem::path configPath = std::filesystem::path(folder) / "dropshell-tool-config.json"; + std::filesystem::path configPath = std::filesystem::path(folder) / "getpkg-config.json"; if (!std::filesystem::exists(configPath)) { - std::cerr << "dropshell-tool-config.json not found in " << folder << std::endl; + std::cerr << "getpkg-config.json not found in " << folder << std::endl; return 1; } std::filesystem::path archivePath = std::filesystem::path(home) / ".tmp" / (labeltag + ".tgz"); @@ -205,12 +205,12 @@ int publish_tool(int argc, char* argv[]) { int update_tool(int argc, char* argv[]) { if (argc < 3) { - std::cerr << "Usage: dropshell-tool update " << std::endl; + std::cerr << "Usage: getpkg update " << std::endl; return 1; } std::string toolName = argv[2]; std::string home = get_home(); - std::filesystem::path configDir = std::filesystem::path(home) / ".config/dropshell-tool"; + std::filesystem::path configDir = std::filesystem::path(home) / ".config/getpkg"; if (toolName == "all") { for (const auto& entry : std::filesystem::directory_iterator(configDir)) { if (entry.path().extension() == ".json") { @@ -247,7 +247,7 @@ int update_tool(int argc, char* argv[]) { int create_tool(int argc, char* argv[]) { if (argc < 4) { - std::cerr << "Usage: dropshell-tool create " << std::endl; + std::cerr << "Usage: getpkg create " << std::endl; return 1; } std::string toolName = argv[2]; @@ -259,7 +259,7 @@ int create_tool(int argc, char* argv[]) { } else { std::cout << "Directory already exists: " << toolDir << std::endl; } - std::filesystem::path configPath = toolDir / "dropshell-tool-config.json"; + std::filesystem::path configPath = toolDir / "getpkg-config.json"; if (!std::filesystem::exists(configPath)) { nlohmann::json config = { {"aliases", nlohmann::json::array()}, @@ -289,7 +289,7 @@ int create_tool(int argc, char* argv[]) { int main(int argc, char* argv[]) { if (argc < 2) { - std::cout << "Usage: dropshell-tool [args...]" << std::endl; + std::cout << "Usage: getpkg [args...]" << std::endl; return 1; } std::string command = argv[1]; @@ -313,7 +313,7 @@ help } else if (command == "create") { return create_tool(argc, argv); } else if (command == "help") { - std::cout << "Usage: dropshell-tool [args...]" << std::endl; + std::cout << "Usage: getpkg [args...]" << std::endl; std::cout << "Commands:" << std::endl; std::cout << " install " << std::endl; std::cout << " publish " << std::endl; diff --git a/getpkg/test.sh b/getpkg/test.sh index 466feb7..11bab76 100755 --- a/getpkg/test.sh +++ b/getpkg/test.sh @@ -2,8 +2,10 @@ set -euo pipefail +PROJECT="getpkg" + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -VERSION=$("${SCRIPT_DIR}/output/dropshell-tool" version) +VERSION=$("${SCRIPT_DIR}/output/${PROJECT}" version) echo "Version: $VERSION" diff --git a/whatsdirty/install.sh b/whatsdirty/install.sh index 89098db..0fee1c5 100755 --- a/whatsdirty/install.sh +++ b/whatsdirty/install.sh @@ -6,15 +6,15 @@ set -euo pipefail echo "Installing whatsdirty" -if ! command -v dropshell-tool ; then +if ! command -v getpkg ; then ARCH=$(uname -m) - wget "https://getbin.xyz/dropshell-tool:latest-${ARCH}" -O bootstrap && chmod a+x bootstrap - ./bootstrap install dropshell-tool + wget "https://getbin.xyz/getpkg:latest-${ARCH}" -O bootstrap && chmod a+x bootstrap + ./bootstrap install getpkg rm ./bootstrap - VERSION=$(dropshell-tool version) + VERSION=$(getpkg version) echo "Dropshell tool $VERSION installed" fi -dropshell-tool install whatsdirty +getpkg install whatsdirty