Skip to content

Commit 57ff628

Browse files
committed
Make it so that "tectonic -Z help" actually works
Closes #1064.
1 parent 6330269 commit 57ff628

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/bin/tectonic/main.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
33
// Licensed under the MIT License.
44

55
use std::{env, process, str::FromStr};
@@ -56,14 +56,26 @@ struct CliOptions {
5656
compile: compile::CompileOptions,
5757
}
5858

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+
5968
fn main() {
6069
let os_args: Vec<_> = env::args_os().collect();
6170

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.
6476

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());
6779
}
6880

6981
// Migration to the "cargo-style" command-line interface. If the first

0 commit comments

Comments
 (0)