2626
2727struct KafkaConfigs {
2828 std::string bootstrap_servers = " localhost:9092" ;
29- std::string token = " " ;
29+ std::string token;
3030};
3131
3232struct LogConfigs {
@@ -39,7 +39,7 @@ struct LogConfigs {
3939
4040class Configs : public SubCommand {
4141public:
42- Configs (argparse::ArgumentParser &parent) : SubCommand(" configs" ) {
42+ explicit Configs (argparse::ArgumentParser &parent) : SubCommand(" configs" ) {
4343 update_command_.add_description (" Update key-value from the INI section" );
4444 update_command_.add_argument (" --kafka-url" )
4545 .help (" The Kafka bootstrap.servers" );
@@ -55,15 +55,15 @@ class Configs : public SubCommand {
5555 if (!std::filesystem::exists (file)) {
5656 continue ;
5757 }
58- if (loadFile (file)) {
58+ if (load_file (file)) {
5959 break ;
6060 }
6161 }
6262 if (config_file_.empty ()) {
6363 config_file_ = std::filesystem::current_path () / " sncloud.ini" ;
6464 std::cout << " No config file found. Creating " << config_file_
6565 << " with the default configs" << std::endl;
66- saveFile ();
66+ save_file ();
6767 }
6868 }
6969
@@ -98,7 +98,7 @@ class Configs : public SubCommand {
9898 }
9999 }
100100 if (updated) {
101- saveFile ();
101+ save_file ();
102102 std::cout << " Updated config file " << config_file_ << std::endl;
103103 } else {
104104 std::cout << " No config updated" << std::endl;
@@ -122,16 +122,16 @@ class Configs : public SubCommand {
122122 KafkaConfigs kafka_configs_;
123123 LogConfigs log_configs_;
124124
125- std::optional<std::string> getValue (const std::string §ion,
126- const std::string &key) {
127- auto value = ini_.GetValue (section.c_str (), key.c_str ());
125+ std::optional<std::string> get_value (const std::string §ion,
126+ const std::string &key) {
127+ const auto * value = ini_.GetValue (section.c_str (), key.c_str ());
128128 if (value == nullptr ) {
129129 return std::nullopt ;
130130 }
131131 return std::optional (value);
132132 }
133133
134- bool loadFile (const std::string &file) {
134+ bool load_file (const std::string &file) {
135135 if (auto rc = ini_.LoadFile (file.c_str ()); rc != SI_OK) {
136136 std::cerr << " Failed to load existing file " << file << " : " << rc
137137 << std::endl;
@@ -143,20 +143,20 @@ class Configs : public SubCommand {
143143 log_configs_ = {};
144144
145145 // load configs from the INI file
146- if (auto value = getValue (" kafka" , " bootstrap.servers" ); value) {
146+ if (auto value = get_value (" kafka" , " bootstrap.servers" ); value) {
147147 kafka_configs_.bootstrap_servers = *value;
148148 } else {
149149 std::cerr << " No bootstrap.servers found in the kafka section. Use the "
150150 " default value: "
151151 << kafka_configs_.bootstrap_servers << std::endl;
152152 }
153- if (auto value = getValue (" kafka" , " token" ); value) {
153+ if (auto value = get_value (" kafka" , " token" ); value) {
154154 kafka_configs_.token = *value;
155155 }
156- if (auto value = getValue (" log" , " enabled" ); value) {
156+ if (auto value = get_value (" log" , " enabled" ); value) {
157157 log_configs_.enabled = std::string (*value) != " false" ;
158158 if (log_configs_.enabled ) {
159- if (auto value = getValue (" log" , " path" ); value) {
159+ if (auto value = get_value (" log" , " path" ); value) {
160160 log_configs_.path = *value;
161161 }
162162 }
@@ -166,7 +166,7 @@ class Configs : public SubCommand {
166166 return true ;
167167 }
168168
169- void saveFile () {
169+ void save_file () {
170170 ini_.SetValue (" kafka" , " bootstrap.servers" ,
171171 kafka_configs_.bootstrap_servers .c_str ());
172172 ini_.SetValue (" kafka" , " token" , kafka_configs_.token .c_str ());
0 commit comments