44** Author Francois Michaut
55**
66** Started on Sat Nov 11 11:06:03 2023 Francois Michaut
7- ** Last update Fri Aug 22 17:19:40 2025 Francois Michaut
7+ ** Last update Sun Aug 24 20:04:30 2025 Francois Michaut
88**
99** main.cpp : Main entry point of FileShare CLI
1010*/
2929#define EXECUTE_ARG " --execute"
3030#define CONFIG_ARG " --config"
3131#define SERVER_CONFIG_ARG " --server-config"
32+ #define DEFAULT_CONFIG_ARG " --default-config"
33+ #define DEFAULT_SERVER_CONFIG_ARG " --default-server-config"
3234
3335void interactive_mode (FileShare::Server &server);
3436
@@ -49,6 +51,14 @@ static auto setup_args() -> std::shared_ptr<argparse::ArgumentParser> {
4951 .default_value (" " )
5052 .help (" Speficy the path to the peer config file." );
5153
54+ parser->add_argument (DEFAULT_SERVER_CONFIG_ARG)
55+ .flag ()
56+ .help (" Use the default server config." );
57+
58+ parser->add_argument (DEFAULT_CONFIG_ARG)
59+ .flag ()
60+ .help (" Use the default peer config." );
61+
5262 parser->add_argument (" -c" , CONNECT_ARG)
5363 .nargs (1 , 2 )
5464 .help (" Connect to an external server. Format '-c ip [port]'. Required to execute commands." );
@@ -124,13 +134,29 @@ static void run_server(FileShare::Server &server) {
124134 }
125135}
126136
127- static void run (std::shared_ptr<argparse::ArgumentParser> &parser) {
137+ static auto get_server_config (std::shared_ptr<argparse::ArgumentParser> &parser) -> FileShare::ServerConfig {
128138 auto server_config_path = parser->get <std::string>(SERVER_CONFIG_ARG);
139+
140+ if (parser->get <bool >(DEFAULT_SERVER_CONFIG_ARG)) {
141+ return FileShare::Server::default_config ();
142+ }
143+ return FileShare::ServerConfig::load (server_config_path);
144+ }
145+
146+ static auto get_default_peer_config (std::shared_ptr<argparse::ArgumentParser> &parser) -> FileShare::Config {
129147 auto config_path = parser->get <std::string>(CONFIG_ARG);
148+
149+ if (parser->get <bool >(DEFAULT_CONFIG_ARG)) {
150+ return FileShare::Server::default_peer_config ();
151+ }
152+ return FileShare::Config::load (config_path);
153+ }
154+
155+ static void run (std::shared_ptr<argparse::ArgumentParser> &parser) {
130156 auto cmds = parser->get <std::vector<std::string>>(EXECUTE_ARG);
131157
132- FileShare::ServerConfig config = FileShare::ServerConfig::load (server_config_path );
133- FileShare::Config peer_config = FileShare::Config::load (config_path );
158+ FileShare::ServerConfig config = get_server_config (parser );
159+ FileShare::Config peer_config = get_default_peer_config (parser );
134160
135161 config.set_server_disabled (!parser->get <bool >(SERVER_ARG));
136162 FileShare::Server server (config, peer_config);
0 commit comments