- Notifications
You must be signed in to change notification settings - Fork 286
/
Copy pathmain.rs
40 lines (29 loc) · 999 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#![cfg_attr(feature = "fail-on-deprecated", deny(deprecated))]
use anyhow::Result;
use clap::{CommandFactory,Parser};
use human_panic::setup_panic;
use onefetch::cli::{self,CliOptions};
use onefetch::info::build_info;
use onefetch::ui::printer::Printer;
use std::io;
fnmain() -> Result<()>{
setup_panic!();
#[cfg(windows)]
enable_ansi_support::enable_ansi_support()?;
let cli_options = cli::CliOptions::parse();
if cli_options.other.languages{
return cli::print_supported_languages();
}
if cli_options.other.package_managers{
return cli::print_supported_package_managers();
}
ifletSome(generator) = cli_options.developer.completion{
letmut cmd = CliOptions::command();
cli::print_completions(generator,&mut cmd);
returnOk(());
}
let info = build_info(&cli_options)?;
letmut printer = Printer::new(io::BufWriter::new(io::stdout()), info, cli_options)?;
printer.print()?;
Ok(())
}