|
1 | | -// src/bin/tectonic.rs -- Command-line driver for the Tectonic engine. |
2 | | -// Copyright 2016-2022 the Tectonic Project |
| 1 | +// src/bin/tectonic/main.rs -- Command-line driver for the Tectonic engine. |
| 2 | +// Copyright 2016-2023 the Tectonic Project |
3 | 3 | // Licensed under the MIT License. |
4 | 4 |
|
5 | 5 | use std::{env, process, str::FromStr}; |
@@ -56,14 +56,26 @@ struct CliOptions { |
56 | 56 | compile: compile::CompileOptions, |
57 | 57 | } |
58 | 58 |
|
| 59 | +#[derive(StructOpt)] |
| 60 | +struct PeekUnstableOptions { |
| 61 | + #[structopt(name = "option", short = "Z", number_of_values = 1)] |
| 62 | + unstable: Vec<unstable_opts::UnstableArg>, |
| 63 | + |
| 64 | + #[structopt()] |
| 65 | + _remainder: Vec<std::ffi::OsString>, |
| 66 | +} |
| 67 | + |
59 | 68 | fn main() { |
60 | 69 | let os_args: Vec<_> = env::args_os().collect(); |
61 | 70 |
|
62 | | - // A hack so that you can just run `tectonic -Zhelp` without getting a usage |
63 | | - // error. Note that `tectonic -Z help` won't work. |
| 71 | + // A hack so that you can just run `tectonic -Z help` without getting a |
| 72 | + // usage error about a missing input file specification. If |
| 73 | + // `from_unstable_args()` sees a `help` option, it will print the usage and |
| 74 | + // exit. Otherwise, this will all be a no-op, and we'll re-parse the args |
| 75 | + // "for real" momentarily. |
64 | 76 |
|
65 | | - if os_args.iter().any(|s| s == "-Zhelp") { |
66 | | - unstable_opts::print_unstable_help_and_exit(); |
| 77 | + if let Ok(args) = PeekUnstableOptions::from_args_safe() { |
| 78 | + unstable_opts::UnstableOptions::from_unstable_args(args.unstable.into_iter()); |
67 | 79 | } |
68 | 80 |
|
69 | 81 | // Migration to the "cargo-style" command-line interface. If the first |
|
0 commit comments