Refactor now mostly working
This commit is contained in:
14
src/main.cpp
14
src/main.cpp
@ -5,6 +5,7 @@
|
||||
#include "servers.hpp"
|
||||
#include "utils/directories.hpp"
|
||||
#include "config.hpp"
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -67,6 +68,13 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// don't load old config if we're initializing
|
||||
if (cmd == "init") {
|
||||
std::string lcd;
|
||||
if (boost::filesystem::exists(dropshell::get_local_dropshell_config_path())) {
|
||||
std::cerr << "DropShell is already initialised in " << dropshell::get_local_dropshell_config_path() << std::endl;
|
||||
std::cerr << "Please manually delete this old config file and re-run the init command." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc < 3) {
|
||||
std::cerr << "Error: init command requires a directory argument" << std::endl;
|
||||
return 1;
|
||||
@ -75,7 +83,7 @@ int main(int argc, char* argv[]) {
|
||||
cfg->init_local_config_directory(argv[2]);
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
std::cerr << "Error in init: " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -105,8 +113,10 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
if (cmd == "autocomplete_list_commands") {
|
||||
commands.merge(std::set<std::string>{
|
||||
"help","version","init"
|
||||
"help","version"
|
||||
});
|
||||
if (!boost::filesystem::exists(dropshell::get_local_dropshell_config_path()))
|
||||
commands.insert("init");
|
||||
if (cfg->is_config_set())
|
||||
commands.merge(std::set<std::string>{
|
||||
"servers","templates","install","backup"
|
||||
|
Reference in New Issue
Block a user