1717namespace file_manager_utils {
1818constexpr std::string_view kCortexConfigurationFileName = " .cortexrc" ;
1919constexpr std::string_view kDefaultConfigurationPath = " user_home" ;
20+ constexpr std::string_view kBetaVariant = " beta" ;
21+ constexpr std::string_view kNightlyVariant = " nightly" ;
2022
2123inline std::filesystem::path GetExecutableFolderContainerPath () {
2224#if defined(__APPLE__) && defined(__MACH__)
@@ -75,13 +77,34 @@ inline std::filesystem::path GetHomeDirectoryPath() {
7577}
7678
7779inline std::filesystem::path GetConfigurationPath () {
80+ #ifndef CORTEX_CONFIG_FILE_PATH
81+ #define CORTEX_CONFIG_FILE_PATH " user_home"
82+ #endif
83+
84+ #ifndef CORTEX_VARIANT
85+ #define CORTEX_VARIANT " prod"
86+ #endif
7887 std::string config_file_path{CORTEX_CONFIG_FILE_PATH};
7988
8089 if (config_file_path != kDefaultConfigurationPath ) {
90+ CTL_INF (" Config file path: " + config_file_path);
8191 return std::filesystem::path (config_file_path);
8292 }
93+
94+ std::string variant{CORTEX_VARIANT};
95+ std::string env_postfix{" " };
96+ if (variant == kBetaVariant ) {
97+ env_postfix.append (" -" ).append (kBetaVariant );
98+ } else if (variant == kNightlyVariant ) {
99+ env_postfix.append (" -" ).append (kNightlyVariant );
100+ }
101+
102+ std::string config_file_name{kCortexConfigurationFileName };
103+ config_file_name.append (env_postfix);
104+ CTL_INF (" Config file name: " + config_file_name);
105+
83106 auto home_path = GetHomeDirectoryPath ();
84- auto configuration_path = home_path / kCortexConfigurationFileName ;
107+ auto configuration_path = home_path / config_file_name ;
85108 return configuration_path;
86109}
87110
@@ -91,15 +114,30 @@ inline void CreateConfigFileIfNotExist() {
91114 // already exists
92115 return ;
93116 }
117+ #ifndef CORTEX_VARIANT
118+ #define CORTEX_VARIANT " prod"
119+ #endif
120+ std::string default_data_folder_name{config_yaml_utils::kCortexFolderName };
121+
122+ std::string variant{CORTEX_VARIANT};
123+ std::string env_postfix{" " };
124+ if (variant == kBetaVariant ) {
125+ env_postfix.append (" -" ).append (kBetaVariant );
126+ } else if (variant == kNightlyVariant ) {
127+ env_postfix.append (" -" ).append (kNightlyVariant );
128+ }
129+ default_data_folder_name.append (env_postfix);
130+
94131 CLI_LOG (" Config file not found. Creating one at " + config_path.string ());
95132 auto defaultDataFolderPath =
96- file_manager_utils::GetHomeDirectoryPath () / config_yaml_utils::kCortexFolderName ;
133+ file_manager_utils::GetHomeDirectoryPath () / default_data_folder_name;
134+ CTL_INF (" Default data folder path: " + defaultDataFolderPath.string ());
135+
97136 auto config = config_yaml_utils::CortexConfig{
98137 .dataFolderPath = defaultDataFolderPath.string (),
99138 .host = config_yaml_utils::kDefaultHost ,
100139 .port = config_yaml_utils::kDefaultPort ,
101140 };
102- std::cout << " config: " << config.dataFolderPath << " \n " ;
103141 DumpYamlConfig (config, config_path.string ());
104142}
105143
@@ -116,8 +154,7 @@ inline std::filesystem::path GetCortexDataPath() {
116154 auto config = GetCortexConfig ();
117155 std::filesystem::path data_folder_path;
118156 if (!config.dataFolderPath .empty ()) {
119- data_folder_path =
120- std::filesystem::path (config.dataFolderPath );
157+ data_folder_path = std::filesystem::path (config.dataFolderPath );
121158 } else {
122159 auto home_path = GetHomeDirectoryPath ();
123160 data_folder_path = home_path / config_yaml_utils::kCortexFolderName ;
0 commit comments