Tidy
This commit is contained in:
parent
7d3209cdb2
commit
4d3523a346
@ -42,7 +42,7 @@ bool config::load_config() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Local config path: " << mLocalConfigPath << std::endl;
|
||||
//std::cout << "Local config path: " << mLocalConfigPath << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ _dropshell_completions() {
|
||||
|
||||
# add all commands to opts
|
||||
local commands=($(dropshell autocomplete_list_commands))
|
||||
# echo "commands: ${commands[*]}"
|
||||
opts="${opts} ${commands[*]}"
|
||||
|
||||
# If we're completing the first argument, show all commands
|
||||
@ -24,29 +25,7 @@ _dropshell_completions() {
|
||||
COMPREPLY=()
|
||||
return 0
|
||||
;;
|
||||
servers)
|
||||
# Show available server names for servers command
|
||||
local servers=($(dropshell autocomplete_list_servers))
|
||||
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
install|backup)
|
||||
# Handle completion for run/install/backup commands
|
||||
if [[ ${COMP_CWORD} -eq 2 ]]; then
|
||||
# Second argument is server name
|
||||
local servers=($(dropshell autocomplete_list_servers))
|
||||
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
|
||||
return 0
|
||||
elif [[ ${COMP_CWORD} -eq 3 ]]; then
|
||||
# Third argument is service name
|
||||
local server_name="${COMP_WORDS[2]}"
|
||||
local services=($(dropshell autocomplete_list_services "$server_name"))
|
||||
COMPREPLY=( $(compgen -W "${services[*]}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# if ${prev} is not in ${commands}
|
||||
if [[ ! " ${commands[*]} " =~ " ${root} " ]]; then
|
||||
COMPREPLY=()
|
||||
return 0
|
||||
|
17
src/main.cpp
17
src/main.cpp
@ -5,6 +5,7 @@
|
||||
#include "servers.hpp"
|
||||
#include "utils/directories.hpp"
|
||||
#include "templates.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <iostream>
|
||||
@ -22,7 +23,8 @@ void print_version() {
|
||||
|
||||
|
||||
void print_help() {
|
||||
std::cout << "Usage: dropshell [OPTIONS] COMMAND [ARGS]" << std::endl;
|
||||
std::cout << std::endl;
|
||||
maketitle("DropShell version " + VERSION);
|
||||
std::cout << std::endl;
|
||||
std::cout << "A tool for managing server configurations" << std::endl;
|
||||
std::cout << std::endl;
|
||||
@ -30,19 +32,18 @@ void print_help() {
|
||||
std::cout << " version Show version information" << std::endl;
|
||||
std::cout << " init DIR Initialise the local dropshell directory (local config, backups, etc)" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Server commands:" << std::endl;
|
||||
std::cout << " servers Summary of all configured servers" << std::endl;
|
||||
std::cout << " servers NAME Show details for specific server" << std::endl;
|
||||
std::cout << " templates List all available templates" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Service commands: (if no service is specified, all services for the server are affected)" << std::endl;
|
||||
std::cout << " install SERVER [SERVICE] Install/Update service(s)." << std::endl;
|
||||
std::cout << " backup SERVER [SERVICE] Backup service(s)." << std::endl;
|
||||
std::cout << " uninstall SERVER [SERVICE] Uninstall service(s)." << std::endl;
|
||||
std::cout << " start SERVER [SERVICE] Start service(s)." << std::endl;
|
||||
std::cout << " stop SERVER [SERVICE] Stop service(s)." << std::endl;
|
||||
std::cout << " COMMAND SERVER [SERVICE] Run a command on service(s)." << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Standard commands: install, backup, uninstall, start, stop" << std::endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
} // namespace dropshell
|
||||
@ -170,6 +171,10 @@ int main(int argc, char* argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string lcd;
|
||||
cfg->get_local_config_directory(lcd);
|
||||
std::cout << "Local config path: " << lcd << std::endl;
|
||||
|
||||
// No arguments provided
|
||||
if (argc < 2) {
|
||||
dropshell::print_help();
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "servers.hpp"
|
||||
#include "server_env.hpp"
|
||||
#include "service_runner.hpp"
|
||||
#include "tableprint.hpp"
|
||||
#include "utils/tableprint.hpp"
|
||||
#include "utils/envmanager.hpp"
|
||||
#include "utils/directories.hpp"
|
||||
#include "services.hpp"
|
||||
|
@ -2,9 +2,9 @@
|
||||
#include "service_runner.hpp"
|
||||
#include "server_env.hpp"
|
||||
#include "templates.hpp"
|
||||
#include "config.hpp"
|
||||
#include "services.hpp"
|
||||
#include "utils/directories.hpp"
|
||||
#include "utils/utils.hpp"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -104,12 +104,6 @@ bool service_runner::execute_local_command(const std::string& command, const std
|
||||
return okay;
|
||||
}
|
||||
|
||||
void service_runner::maketitle(const std::string& title) const {
|
||||
std::cout << std::string(title.length() + 4, '-') << std::endl;
|
||||
std::cout << "| " << title << " |" << std::endl;
|
||||
std::cout << std::string(title.length() + 4, '-') << std::endl;
|
||||
}
|
||||
|
||||
bool service_runner::install() {
|
||||
maketitle("Installing " + m_service_info.service_name + " (" + m_service_info.template_name + ") on " + m_server_name);
|
||||
|
||||
|
@ -90,7 +90,6 @@ class service_runner {
|
||||
bool check_remote_items_exist(const std::vector<std::string>& file_paths) const;
|
||||
bool execute_ssh_command(const std::string& command, const std::string& error_msg) const;
|
||||
bool execute_local_command(const std::string& command, const std::string& error_msg) const;
|
||||
void maketitle(const std::string& title) const;
|
||||
};
|
||||
|
||||
} // namespace dropshell
|
||||
|
13
src/utils/utils.cpp
Normal file
13
src/utils/utils.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "utils.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace dropshell {
|
||||
|
||||
void maketitle(const std::string& title) {
|
||||
std::cout << std::string(title.length() + 4, '-') << std::endl;
|
||||
std::cout << "| " << title << " |" << std::endl;
|
||||
std::cout << std::string(title.length() + 4, '-') << std::endl;
|
||||
}
|
||||
|
||||
} // namespace dropshell
|
14
src/utils/utils.hpp
Normal file
14
src/utils/utils.hpp
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace dropshell {
|
||||
|
||||
/**
|
||||
* Prints a formatted title surrounded by a box of dashes.
|
||||
*
|
||||
* @param title The title string to display
|
||||
*/
|
||||
void maketitle(const std::string& title);
|
||||
|
||||
} // namespace dropshell
|
Loading…
x
Reference in New Issue
Block a user