using boost::program_options::parsed_options;
using boost::program_options::positional_options_description;
using boost::program_options::variables_map;
-using boost::program_options::collect_unrecognized;
-using boost::program_options::include_positional;
using I2n::Logger::GlobalLogger;
//-----------------------------------------------------------------------------
parsed_options parsed_opt = command_line_parser( argc, const_cast<char**>( argv ) ).
options( cmdline_options ).
positional( p ).
- allow_unregistered().
run();
-
- // TODO not sure whether the "allow_unregistered()" above is required or not
- // Because of this option, it is easy to make mistakes in options, so at least
- // warn
- vector<string> unrecognized_options = collect_unrecognized(parsed_opt.options,
- include_positional);
- if ( !unrecognized_options.empty() )
- {
- GlobalLogger.warning() << "Accepted unrecognized options" << endl;
- }
-
store( parsed_opt, *vm );
notify( *vm );
}
catch ( const std::exception &ex )
{
- GlobalLogger.error() << ex.what() << endl;
+ GlobalLogger.error() << "Error parsing command line options: " << ex.what() << endl;
+
+ if (true) // TODO: if GlobalLogger is not logging to console
+ { // ensure that error about command line options shows on command line
+ cerr << "Error parsing command line options: " << ex.what() << endl;
+ }
+
return false;
}
}
string file_name = Config.get_config_file_name();
+ if (file_name.empty())
+ {
+ return false; // otherwise only get message about failed
+ // file name assertion which is confusing because error lies elsewhere
+ }
+
ConfigurationFile file( file_name );
bool configuration_file_processed = file.process( &vm );
if ( configuration_file_processed )
Configuration config_obj = config_reader.get_configuration();
configuration.reset( new Configuration( config_obj ) );
}
- else
- {
- GlobalLogger.error() << "Failed to parse options from command line and/or config file! "
- << "Continue with standard values." << endl;
- }
return configuration;
}