()
| 293 | fn ignore_sigpipe() {} |
| 294 | |
| 295 | fn main() -> Result<()> { |
| 296 | // A normal Unix CLI exits quietly when a downstream consumer closes the pipe |
| 297 | // early (a pager quitting, `head`, `| grep -q`); `serve` overrides this below. |
| 298 | restore_default_sigpipe(); |
| 299 | |
| 300 | let cli = Cli::parse(); |
| 301 | match cli.cmd { |
| 302 | Cmd::DebugWatch { path, debounce_ms } => debug_watch::run(&path, debounce_ms), |
| 303 | Cmd::Validate => cmd_validate(), |
| 304 | Cmd::Lint => cmd_lint(), |
| 305 | Cmd::Show { fmt, downstream } => cmd_show(&fmt, downstream.as_deref()), |
| 306 | Cmd::Reply { run } => cmd_reply(run), |
| 307 | Cmd::Serve { scope, port, open } => { |
| 308 | // Unlike the one-shot CLI commands, the server must survive a client |
| 309 | // disconnecting mid-response, so keep SIGPIPE ignored. |
| 310 | ignore_sigpipe(); |
| 311 | let runtime = tokio::runtime::Builder::new_multi_thread() |
| 312 | .enable_all() |
| 313 | .build()?; |
| 314 | runtime.block_on(serve::run(&scope, port, open)) |
| 315 | } |
| 316 | Cmd::Completion { shell } => cmd_completion(&shell), |
| 317 | Cmd::Run { action } => cmd_run(action), |
| 318 | Cmd::Step { |
| 319 | step_id, |
| 320 | status, |
| 321 | message, |
| 322 | assets, |
| 323 | run, |
| 324 | } => cmd_step(step_id, status, message, assets, run), |
| 325 | Cmd::Deliverable { |
| 326 | status, |
| 327 | message, |
| 328 | assets, |
| 329 | run, |
| 330 | } => cmd_deliverable(status, message, assets, run), |
| 331 | Cmd::Explain { path, output } => { |
| 332 | print!("{}", explain::explain(&path, output)?); |
| 333 | Ok(()) |
| 334 | } |
| 335 | Cmd::Init { slug } => cmd_init(&slug), |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | fn cmd_init(slug: &str) -> Result<()> { |
| 340 | validate_trace_id(slug) |
nothing calls this directly
no test coverage detected
searching dependent graphs…