MCPcopy Create free account
hub / github.com/PRQL/prql / main

Function main

prqlc/prqlc/src/cli/mod.rs:46–85  ·  view source on GitHub ↗

Entrypoint called by [`crate::main`]

()

Source from the content-addressed store, hash-verified

44
45/// Entrypoint called by [`crate::main`]
46pub fn main() -> color_eyre::eyre::Result<()> {
47 let cli = Cli::parse();
48
49 // redirect all log messages into the [debug::DebugLog]
50 if has_debug_log(&cli) {
51 static LOGGER: debug::MessageLogger = debug::MessageLogger;
52 log::set_logger(&LOGGER)
53 .map(|()| log::set_max_level(log::LevelFilter::max()))
54 .unwrap();
55 }
56
57 color_eyre::install()?;
58 cli.color.write_global();
59
60 if let Some(mut subcommand) = cli.command {
61 if let Err(error) = subcommand.run() {
62 eprintln!("{error}");
63 // Copied from
64 // https://doc.rust-lang.org/src/std/backtrace.rs.html#1-504, since it's private
65 fn backtrace_enabled() -> bool {
66 match env::var("RUST_LIB_BACKTRACE") {
67 Ok(s) => s != "0",
68 Err(_) => match env::var("RUST_BACKTRACE") {
69 Ok(s) => s != "0",
70 Err(_) => false,
71 },
72 }
73 }
74 if backtrace_enabled() {
75 eprintln!("{:#}", error.backtrace());
76 }
77
78 exit(1)
79 }
80 } else {
81 Cli::command().print_help()?;
82 }
83
84 Ok(())
85}
86
87#[derive(Parser, Debug, Clone)]
88struct Cli {

Callers

nothing calls this directly

Calls 5

has_debug_logFunction · 0.85
backtrace_enabledFunction · 0.85
mapMethod · 0.80
parseFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected