Compare commits

...

2 Commits

Author SHA1 Message Date
73c94f34f6 Modify getpkg/src/main.cpp
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 55s
Build-Test-Publish / build (linux/arm64) (push) Successful in 1m23s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Successful in 6s
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Successful in 7s
2025-06-30 23:47:08 +12:00
af4cbbcab0 Update 2 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 54s
Build-Test-Publish / build (linux/arm64) (push) Successful in 1m23s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Successful in 7s
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Successful in 7s
2025-06-30 23:13:51 +12:00
3 changed files with 82 additions and 15 deletions

View File

@ -3,7 +3,7 @@ set -euo pipefail
# Get script directory - handle different execution contexts
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT="$(basename "$(dirname "${SCRIPT_DIR}")")"
PROJECT="$(basename "${SCRIPT_DIR}")"
# Debug output for CI
echo "${PROJECT} build script running from: ${SCRIPT_DIR}"

View File

@ -3,7 +3,7 @@ set -euo pipefail
# Get script directory - handle different execution contexts
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT="$(basename "$(dirname "${SCRIPT_DIR}")")"
PROJECT="$(basename "${SCRIPT_DIR}")"
# Debug output for CI
echo "${PROJECT} build script running from: ${SCRIPT_DIR}"

View File

@ -1150,6 +1150,85 @@ void show_help() {
std::cout << " ~/.local/bin/getpkg/ Installed tool binaries" << std::endl;
}
int autocomplete_command(int argc, char* argv[]) {
std::vector<std::string> args(argv + 2, argv + argc);
// If no arguments, return all commands
if (args.empty()) {
std::cout << "install\n";
std::cout << "uninstall\n";
std::cout << "publish\n";
std::cout << "unpublish\n";
std::cout << "update\n";
std::cout << "version\n";
std::cout << "create\n";
std::cout << "hash\n";
std::cout << "list\n";
std::cout << "clean\n";
std::cout << "help\n";
return 0;
}
const std::string& subcommand = args[0];
// Handle autocompletion for specific commands
if (subcommand == "install") {
// For install, we could suggest popular packages or recently published ones
// For now, just return empty (no specific completions)
return 0;
} else if (subcommand == "uninstall") {
// For uninstall, list installed tools
std::filesystem::path configDir = std::filesystem::path(std::getenv("HOME")) / ".config" / "getpkg";
if (std::filesystem::exists(configDir)) {
for (const auto& entry : std::filesystem::directory_iterator(configDir)) {
if (entry.path().extension() == ".json") {
std::string toolName = entry.path().stem().string();
std::cout << toolName << "\n";
}
}
}
return 0;
} else if (subcommand == "publish") {
// For publish, suggest architecture suffixes after tool name
if (args.size() >= 2) {
// If we have tool_name already, suggest architectures
std::cout << "x86_64\n";
std::cout << "aarch64\n";
std::cout << "universal\n";
}
return 0;
} else if (subcommand == "unpublish") {
// For unpublish, list installed tools (similar to uninstall)
std::filesystem::path configDir = std::filesystem::path(std::getenv("HOME")) / ".config" / "getpkg";
if (std::filesystem::exists(configDir)) {
for (const auto& entry : std::filesystem::directory_iterator(configDir)) {
if (entry.path().extension() == ".json") {
std::string toolName = entry.path().stem().string();
std::cout << toolName << "\n";
// Also suggest with architecture suffixes
std::cout << toolName << ":x86_64\n";
std::cout << toolName << ":aarch64\n";
std::cout << toolName << ":universal\n";
}
}
}
return 0;
} else if (subcommand == "create") {
// For create, no specific completions (tool name and directory are user-defined)
return 0;
} else if (subcommand == "hash") {
// For hash, suggest file extensions
if (args.size() >= 2) {
std::cout << "*.tgz\n";
std::cout << "*.tar.gz\n";
}
return 0;
}
// No specific completions for other commands
return 0;
}
} // end anonymous namespace
int main(int argc, char* argv[]) {
@ -1169,19 +1248,7 @@ int main(int argc, char* argv[]) {
} else if (command == "update") {
return update_tool(argc, argv);
} else if (command == "autocomplete") {
std::vector<std::string> args(argv + 2, argv + argc);
if (args.empty()) std::cout << R"(install
uninstall
publish
unpublish
update
version
create
hash
list
clean
help
)";
return autocomplete_command(argc, argv);
} else if (command == "version") {
std::cout << dropshell::VERSION << std::endl;
} else if (command == "create") {