Commit 0b2cc8c1 authored by Farzeen's avatar Farzeen

Fixed mixed indentation

parent 8d782289
......@@ -9,7 +9,7 @@ class Configuration {
public:
string get_dotcastle_dir();
/* Currently, the caller is responsible for expanding env vars in
/* Currently, the caller is responsible for expanding env vars in
* dotcastle_config_file path string.
* Should it be the responsibility of this class? */
Configuration(string dotcastle_config_file);
......
......@@ -2,7 +2,7 @@
#include "Exceptions.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/convenience.hpp>
#include "cpp-subprocess/subprocess.hpp"
#include "cpp-subprocess/subprocess.hpp"
using namespace std;
namespace fs = boost::filesystem;
......@@ -20,7 +20,7 @@ list<App> AppMgr::list_apps() {
for(auto itr: dotcastle_dir_itr) {
auto dir_ent_path = itr.path();
if(!fs::is_directory(dir_ent_path)) continue;
auto app_name = dir_ent_path.filename().string();
auto app_name = dir_ent_path.filename().string();
app_list.push_back(App {app_name});
}
return app_list;
......@@ -51,9 +51,9 @@ void AppMgr::make_config_group_of_app(ConfigGroup cg, App app) {
if(!fs::is_directory(app_dir_path))
throw NonExistentApp();
auto retcode = proc::call((app_dir_path/(cg.name+".make")).string(),
auto retcode = proc::call((app_dir_path/(cg.name+".make")).string(),
proc::cwd{app_dir_path.string()});
if(retcode!=0)
if(retcode!=0)
throw AppConfigGroupMakeFailed();
}
......@@ -65,6 +65,6 @@ void AppMgr::install_config_group_of_app(ConfigGroup cg, App app) {
auto retcode = proc::call((app_dir_path/(cg.name+".install")).string(),
proc::cwd{app_dir_path.string()});
if(retcode!=0)
if(retcode!=0)
throw AppConfigGroupMakeFailed();
}
......@@ -17,5 +17,5 @@ Configuration::Configuration(string dotcastle_config_file) {
string Configuration::get_dotcastle_dir() {
return dotcastle_dir;
}
......@@ -20,7 +20,7 @@ namespace po = boost::program_options;
// GLOBALS
char *exec_name; // init by main as argv[0]
po::options_description opts_desc;
po::options_description opts_desc;
auto configuration = unique_ptr<Configuration>();
auto app_mgr = unique_ptr<AppMgr>();
// END OF GLOBALS
......@@ -31,8 +31,8 @@ void list_apps();
void list_config_groups();
// Note:
// Signatures of `make` and `install` reflects the CLI syntax
// I don't think there's any significant reason to change that to
// `make(string config, string appname)`
// I don't think there's any significant reason to change that to
// `make(string config, string appname)`
// instead of letting `make` and `install` split the string argument
void make(string config_slash_appname);
void install(string config_slash_appname);
......@@ -40,22 +40,22 @@ void install(string config_slash_appname);
void load_configuration_file(unique_ptr<Configuration> &configuration,
unique_ptr<AppMgr> &app_mgr) {
char *xdg_config_home = getenv("XDG_CONFIG_HOME");
char *home = getenv("HOME");
char *home = getenv("HOME");
auto dotcastle_config_file_path = string{};
auto dotcastle_dir_path = string{};
auto dotcastle_dir_path = string{};
if(xdg_config_home)
dotcastle_config_file_path = string{xdg_config_home}+string{"/dotcastle/dotcastle.conf"};
else
dotcastle_config_file_path = string{home}+string{"/.dotcastle/dotcastle.conf"};
try {
configuration = make_unique<Configuration>(
dotcastle_config_file_path
dotcastle_config_file_path
);
dotcastle_dir_path = configuration->get_dotcastle_dir();
} catch(ConfigurationFileDoesnotExist &e) {
cerr<<"Warning: Failed to load config file from '"<<dotcastle_config_file_path<<"'."<<endl;
cerr<<"Using '"<<home<<"/dotcastle/' as dotcastle directory."<<endl;
dotcastle_dir_path = string{home}+"/dotcastle/";
dotcastle_dir_path = string{home}+"/dotcastle/";
}
app_mgr = make_unique<AppMgr>(dotcastle_dir_path);
......@@ -82,12 +82,12 @@ void process_cli_options_values(const po::variables_map &vm) {
if(vm.count("help")) {
show_help();
return;
}
}
if (vm.count("list")) {
list_all();
return;
}
}
//
if(vm.count("list-config-groups")) {
......@@ -145,7 +145,7 @@ void list_all() {
config_group_apps_map[cg.name].push_back(app.name);
}
}
cout<<"Listing all config-groups and apps: "<<endl;
cout<<"Listing all config-groups and apps: "<<endl;
for(auto pair : config_group_apps_map) {
cout<<" - "<<pair.first<<endl;
for(auto app : pair.second) {
......@@ -170,26 +170,26 @@ void list_config_groups() {
}
void list_apps() {
cout<<"Listing all apps: "<<endl;
cout<<"Listing all apps: "<<endl;
auto apps = app_mgr->list_apps();
for(App app: apps)
cout<<" - "<<app.name<<endl;
}
pair<string,vector<string>>
pair<string,vector<string>>
__parse_config_slash_appname(string config_slash_appname) {
auto slash_pos = config_slash_appname.find("/");
string config_group = config_slash_appname.substr(0,slash_pos);
string config_group = config_slash_appname.substr(0,slash_pos);
vector<string> apps;
if(slash_pos == string::npos ||
if(slash_pos == string::npos ||
slash_pos == config_slash_appname.size() - 1) {
for(auto app: app_mgr->list_apps()) {
auto config_groups = app_mgr->list_config_groups_for_app(app);
auto it = find(
config_groups.begin(),
config_groups.end(),
config_groups.end(),
ConfigGroup{config_group}
);
if(it!=config_groups.end()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment