1717namespace file_manager_utils {
1818constexpr std::string_view kCortexConfigurationFileName = " .cortexrc" ;
1919constexpr std::string_view kDefaultConfigurationPath = " user_home" ;
20+ constexpr std::string_view kProdVariant = " prod" ;
21+ constexpr std::string_view kBetaVariant = " beta" ;
22+ constexpr std::string_view kNightlyVariant = " nightly" ;
2023
2124inline std::filesystem::path GetExecutableFolderContainerPath () {
2225#if defined(__APPLE__) && defined(__MACH__)
@@ -75,13 +78,34 @@ inline std::filesystem::path GetHomeDirectoryPath() {
7578}
7679
7780inline std::filesystem::path GetConfigurationPath () {
81+ #ifndef CORTEX_CONFIG_FILE_PATH
82+ #define CORTEX_CONFIG_FILE_PATH kDefaultConfigurationPath
83+ #endif
84+
85+ #ifndef CORTEX_VARIANT
86+ #define CORTEX_VARIANT kProdVariant
87+ #endif
7888 std::string config_file_path{CORTEX_CONFIG_FILE_PATH};
7989
8090 if (config_file_path != kDefaultConfigurationPath ) {
91+ CTL_INF (" Config file path: " + config_file_path);
8192 return std::filesystem::path (config_file_path);
8293 }
94+
95+ std::string variant{CORTEX_VARIANT};
96+ std::string env_postfix{" " };
97+ if (variant == kBetaVariant ) {
98+ env_postfix.append (" -" ).append (kBetaVariant );
99+ } else if (variant == kNightlyVariant ) {
100+ env_postfix.append (" -" ).append (kNightlyVariant );
101+ }
102+
103+ std::string config_file_name{kCortexConfigurationFileName };
104+ config_file_name.append (env_postfix);
105+ CTL_INF (" Config file name: " + config_file_name);
106+
83107 auto home_path = GetHomeDirectoryPath ();
84- auto configuration_path = home_path / kCortexConfigurationFileName ;
108+ auto configuration_path = home_path / config_file_name ;
85109 return configuration_path;
86110}
87111
@@ -91,15 +115,30 @@ inline void CreateConfigFileIfNotExist() {
91115 // already exists
92116 return ;
93117 }
118+ #ifndef CORTEX_VARIANT
119+ #define CORTEX_VARIANT " prod"
120+ #endif
121+ std::string default_data_folder_name{config_yaml_utils::kCortexFolderName };
122+
123+ std::string variant{CORTEX_VARIANT};
124+ std::string env_postfix{" " };
125+ if (variant == kBetaVariant ) {
126+ env_postfix.append (" -" ).append (kBetaVariant );
127+ } else if (variant == kNightlyVariant ) {
128+ env_postfix.append (" -" ).append (kNightlyVariant );
129+ }
130+ default_data_folder_name.append (env_postfix);
131+
94132 CLI_LOG (" Config file not found. Creating one at " + config_path.string ());
95133 auto defaultDataFolderPath =
96- file_manager_utils::GetHomeDirectoryPath () / config_yaml_utils::kCortexFolderName ;
134+ file_manager_utils::GetHomeDirectoryPath () / default_data_folder_name;
135+ CTL_INF (" Default data folder path: " + defaultDataFolderPath.string ());
136+
97137 auto config = config_yaml_utils::CortexConfig{
98138 .dataFolderPath = defaultDataFolderPath.string (),
99139 .host = config_yaml_utils::kDefaultHost ,
100140 .port = config_yaml_utils::kDefaultPort ,
101141 };
102- std::cout << " config: " << config.dataFolderPath << " \n " ;
103142 DumpYamlConfig (config, config_path.string ());
104143}
105144
@@ -116,8 +155,7 @@ inline std::filesystem::path GetCortexDataPath() {
116155 auto config = GetCortexConfig ();
117156 std::filesystem::path data_folder_path;
118157 if (!config.dataFolderPath .empty ()) {
119- data_folder_path =
120- std::filesystem::path (config.dataFolderPath );
158+ data_folder_path = std::filesystem::path (config.dataFolderPath );
121159 } else {
122160 auto home_path = GetHomeDirectoryPath ();
123161 data_folder_path = home_path / config_yaml_utils::kCortexFolderName ;
0 commit comments