Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid allocating the --help message #12243

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions helix-term/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,15 @@ fn main() -> Result<()> {

#[tokio::main]
async fn main_impl() -> Result<i32> {
let help = format!(
"\
let mut args = Args::parse_args().context("could not parse arguments")?;

helix_loader::initialize_config_file(args.config_file.clone());
helix_loader::initialize_log_file(args.log_file.clone());

// Help has a higher priority and should be handled separately.
if args.display_help {
print!(
"\
{} {}
{}
{}
Expand Down Expand Up @@ -69,21 +76,12 @@ FLAGS:
-w, --working-dir <path> Specify an initial working directory
+N Open the first given file at line number N
",
env!("CARGO_PKG_NAME"),
VERSION_AND_GIT_HASH,
env!("CARGO_PKG_AUTHORS"),
env!("CARGO_PKG_DESCRIPTION"),
helix_loader::default_log_file().display(),
);

let mut args = Args::parse_args().context("could not parse arguments")?;

helix_loader::initialize_config_file(args.config_file.clone());
helix_loader::initialize_log_file(args.log_file.clone());

// Help has a higher priority and should be handled separately.
if args.display_help {
print!("{}", help);
env!("CARGO_PKG_NAME"),
VERSION_AND_GIT_HASH,
env!("CARGO_PKG_AUTHORS"),
env!("CARGO_PKG_DESCRIPTION"),
helix_loader::default_log_file().display(),
);
std::process::exit(0);
}

Expand Down
Loading