Merge pull request #360 from PfaulJulian/main

Changed return type of fn main() in src/main.rs to fn main() -> std::process::ExitCode.
This commit is contained in:
Nicolas Abril 2024-05-18 15:27:47 +02:00 committed by GitHub
commit e94cb78c7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,10 @@ use bend::{
load_file_to_book, run_book_with_fn, CompileOpts, OptLevel, RunOpts, load_file_to_book, run_book_with_fn, CompileOpts, OptLevel, RunOpts,
}; };
use clap::{Args, CommandFactory, Parser, Subcommand}; use clap::{Args, CommandFactory, Parser, Subcommand};
use std::path::{Path, PathBuf}; use std::{
path::{Path, PathBuf},
process::ExitCode,
};
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
@ -222,15 +225,18 @@ pub enum WarningArgs {
RecursionCycle, RecursionCycle,
} }
fn main() { fn main() -> ExitCode {
#[cfg(not(feature = "cli"))] #[cfg(not(feature = "cli"))]
compile_error!("The 'cli' feature is needed for the hvm-lang cli"); compile_error!("The 'cli' feature is needed for the hvm-lang cli");
let cli = Cli::parse(); let cli = Cli::parse();
if let Err(diagnostics) = execute_cli_mode(cli) { if let Err(diagnostics) = execute_cli_mode(cli) {
eprint!("{diagnostics}") eprint!("{diagnostics}");
return ExitCode::FAILURE;
} }
ExitCode::SUCCESS
} }
fn execute_cli_mode(mut cli: Cli) -> Result<(), Diagnostics> { fn execute_cli_mode(mut cli: Cli) -> Result<(), Diagnostics> {