Dropshell!
This commit is contained in:
26
src/main.cpp
26
src/main.cpp
@ -14,14 +14,6 @@
|
||||
#include <iomanip>
|
||||
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<std::string> commands;
|
||||
std::vector<dropshell::ServerInfo> servers = dropshell::get_configured_servers();
|
||||
@ -140,7 +128,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
if (cmd == "autocomplete_list_commands") {
|
||||
commands.merge(std::set<std::string>{
|
||||
"help","version","init"
|
||||
"help","init"
|
||||
});
|
||||
if (cfg->is_config_set())
|
||||
commands.merge(std::set<std::string>{
|
||||
|
Reference in New Issue
Block a user