tidying
This commit is contained in:
23
src/main.cpp
23
src/main.cpp
@ -10,6 +10,7 @@
|
||||
#include "autocomplete.hpp"
|
||||
#include "main_commands.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -25,7 +26,9 @@ void print_help() {
|
||||
std::cout << std::endl;
|
||||
std::cout << "dropshell ..." << std::endl;
|
||||
std::cout << " help Show this help message" << std::endl;
|
||||
std::cout << " init DIR Add DIR as a local configuration directory for dropshell (can add several)" << std::endl;
|
||||
std::cout << " init DIR Add DIR as a local server config directory (can add several)" << std::endl;
|
||||
|
||||
if (get_global_config()->is_config_set()) {
|
||||
std::cout << " server NAME Show details for specific server" << std::endl;
|
||||
std::cout << " templates List all available templates" << std::endl;
|
||||
std::cout << std::endl;
|
||||
@ -44,6 +47,12 @@ void print_help() {
|
||||
std::cout << " create-template TEMPLATE" << std::endl;
|
||||
std::cout << " create-server SERVER" << std::endl;
|
||||
std::cout << " create-service SERVER TEMPLATE SERVICE" << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << " edit Edit the configuration of dropshell" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Other commands available once initialised." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dropshell
|
||||
@ -99,6 +108,12 @@ int main(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cmd == "edit" && argc < 3) {
|
||||
std::filesystem::create_directories(dropshell::get_local_dropshell_config_parent_path());
|
||||
dropshell::edit_file(dropshell::get_local_dropshell_config_file(), "Please ensure any directories you have introduced in the config file exist.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// from here we require the config file to be loaded.
|
||||
if (!cfg->is_config_set()) {
|
||||
@ -173,10 +188,8 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
if (cmd == "edit" && argc < 4) {
|
||||
if (argc < 3)
|
||||
dropshell::edit_file(dropshell::get_local_dropshell_config_path(), "Please ensure any directories you have introduced in the config file exist.");
|
||||
else
|
||||
dropshell::edit_server(argv[2]);
|
||||
ASSERT_ALWAYS(argc>=3);
|
||||
dropshell::edit_server(argv[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user