1 /// The Routinator binary.
2 
3 use std::env::current_dir;
4 use std::process::exit;
5 use clap::{App, crate_authors, crate_version};
6 use log::error;
7 use routinator::{Config, ExitError, Operation};
8 
9 // Since `main` with a result currently insists on printing a message, but
10 // in our case we only get an `ExitError` if all is said and done, we make our
11 // own, more quiet version.
_main() -> Result<(), ExitError>12 fn _main() -> Result<(), ExitError> {
13     Operation::prepare()?;
14     let cur_dir = match current_dir() {
15         Ok(dir) => dir,
16         Err(err) => {
17             error!(
18                 "Fatal: cannot get current directory ({}). Aborting.",
19                 err
20             );
21             return Err(ExitError::Generic);
22         }
23     };
24     let matches = Operation::config_args(Config::config_args(
25         App::new("Routinator")
26             .version(crate_version!())
27             .author(crate_authors!())
28             .about("collects and processes RPKI repository data")
29     )).get_matches();
30     let mut config = Config::from_arg_matches(&matches, &cur_dir)?;
31     let operation = Operation::from_arg_matches(
32         &matches, &cur_dir, &mut config
33     )?;
34     operation.run(config)
35 }
36 
main()37 fn main() {
38     match _main() {
39         Ok(_) => exit(0),
40         Err(ExitError::Generic) => exit(1),
41         Err(ExitError::IncompleteUpdate) => exit(2),
42         Err(ExitError::Invalid) => exit(3),
43     }
44 }
45 
46