From 1d8502d71a65a278c2fb8bde91fc8a9e18acc3dc Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 25 Apr 2025 21:17:11 +1200 Subject: [PATCH] Dropshell! --- README.md | 77 ---------------------------------------------------- src/main.cpp | 26 +++++------------- 2 files changed, 7 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index 460d9d1..5091432 100644 --- a/README.md +++ b/README.md @@ -1,80 +1,3 @@ # Dropshell A system management tool for server operations, written in C++. - -## Features - -- System status monitoring -- Server configuration management -- Bash completion support -- Command-line interface with help and version information - -## Building from Source - -### Prerequisites - -- CMake (>= 3.10) -- Boost C++ Libraries (program_options, filesystem, system) -- C++17 compatible compiler -- Debian packaging tools (for creating packages) - -### Building - -```bash -# Clone the repository -git clone https://github.com/j842/dropshell.git -cd dropshell - -# Create build directory -mkdir build -cd build - -# Configure and build -cmake .. -make -``` - -### Installing - -#### From Source - -```bash -# Install from source build -sudo make install -``` - -#### From Debian Package - -To create a Debian package: - -```bash -# Install build dependencies -sudo apt-get install devscripts debhelper cmake libboost-all-dev - -# Build the package -dpkg-buildpackage -us -uc - -# Install the package -sudo dpkg -i ../dropshell_1.0.0-1_*.deb -``` - -## Usage - -```bash -# Show help -dropshell help - -# Show version -dropshell version - -# List configured servers -dropshell servers -``` - -## Configuration - -The configuration file is located at `/etc/dropshell.conf`. You can modify this file to change default settings. - -## License - -MIT License - see LICENSE file for details \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 67a65e6..ea7bd2c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,14 +14,6 @@ #include namespace dropshell { -void print_version() { - std::cout << "dropshell version " << VERSION << std::endl; - std::cout << "Release date: " << RELEASE_DATE << std::endl; - std::cout << "Author: " << AUTHOR << std::endl; - std::cout << "License: " << LICENSE << std::endl; -} - - void print_help() { std::cout << std::endl; maketitle("DropShell version " + VERSION); @@ -78,16 +70,17 @@ std::string safearg(int argc, char *argv[], int index) int main(int argc, char* argv[]) { try { dropshell::config *cfg = dropshell::get_global_config(); + // silently attempt to load the config file. + cfg->load_config(); if (argc == 1) { - dropshell::print_help(); + dropshell::list_servers(); + std::cout << std::endl; + std::cout << "dropshell help - get help on using dropshell" << std::endl; return 0; } std::string cmd = argv[1]; - // silently attempt to load the config file. - cfg->load_config(); - // don't load old config if we're initializing if (cmd == "init") { std::string lcd; @@ -118,16 +111,11 @@ int main(int argc, char* argv[]) { } } - if (cmd == "help" || cmd == "-h" || cmd == "--help") { + if (cmd == "help" || cmd == "-h" || cmd == "--help" || cmd== "h" || cmd=="halp") { dropshell::print_help(); return 0; } - if (cmd == "version" || cmd == "-V" || cmd == "--version") { - dropshell::print_version(); - return 0; - } - // auto completion stuff. std::set commands; std::vector servers = dropshell::get_configured_servers(); @@ -140,7 +128,7 @@ int main(int argc, char* argv[]) { if (cmd == "autocomplete_list_commands") { commands.merge(std::set{ - "help","version","init" + "help","init" }); if (cfg->is_config_set()) commands.merge(std::set{