MCPcopy Index your code
hub / github.com/encounter/objdiff / main

Function main

objdiff-cli/src/main.rs:100–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98}
99
100fn main() {
101 let args: TopLevel = argp_version::from_env();
102 let use_colors = if args.no_color || env_no_color() {
103 false
104 } else {
105 // Try to enable ANSI support on Windows.
106 let _ = enable_ansi_support();
107 // Disable isatty check for supports-color. (e.g. when used with ninja)
108 unsafe { env::set_var("IGNORE_IS_TERMINAL", "1") };
109 supports_color::on(Stream::Stdout).is_some_and(|c| c.has_basic)
110 };
111
112 let format =
113 tracing_subscriber::fmt::format().with_ansi(use_colors).with_target(false).without_time();
114 let builder = tracing_subscriber::fmt().event_format(format).with_writer(std::io::stderr);
115 if let Some(level) = args.log_level {
116 builder
117 .with_max_level(match level {
118 LogLevel::Error => LevelFilter::ERROR,
119 LogLevel::Warn => LevelFilter::WARN,
120 LogLevel::Info => LevelFilter::INFO,
121 LogLevel::Debug => LevelFilter::DEBUG,
122 LogLevel::Trace => LevelFilter::TRACE,
123 })
124 .init();
125 } else {
126 builder
127 .with_env_filter(
128 EnvFilter::builder()
129 .with_default_directive(LevelFilter::INFO.into())
130 .from_env_lossy(),
131 )
132 .init();
133 }
134
135 let mut result = Ok(());
136 if let Some(dir) = &args.chdir {
137 result = env::set_current_dir(dir).map_err(|e| {
138 Error::new(e)
139 .context(format!("Failed to change working directory to '{}'", dir.display()))
140 });
141 }
142 result = result.and_then(|_| match args.command {
143 SubCommand::Diff(c_args) => cmd::diff::run(c_args),
144 SubCommand::Report(c_args) => cmd::report::run(c_args),
145 });
146 if let Err(e) = result {
147 eprintln!("Failed: {e:?}");
148 std::process::exit(1);
149 }
150}

Callers

nothing calls this directly

Calls 4

env_no_colorFunction · 0.85
initMethod · 0.80
from_envFunction · 0.70
runFunction · 0.50

Tested by

no test coverage detected