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

Ensure there is a non-zero exit code when the programme errors #9

Merged
merged 4 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/config/cargo_crates_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct CargoCratesToml {

impl CargoCratesToml {
/// The default name for the save file in Cargo's home.
pub const FILE_NAME: &str = ".crates.toml";
pub const FILE_NAME: &'static str = ".crates.toml";

/// Returns the [`PathBuf`] pointing to the associated save file.
///
Expand Down
2 changes: 1 addition & 1 deletion src/config/user_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct UserConfig {

impl UserConfig {
/// The default name for the configuration file in Cargo's home.
pub const FILE_NAME: &str = "liner.toml";
pub const FILE_NAME: &'static str = "liner.toml";
PaulDance marked this conversation as resolved.
Show resolved Hide resolved

/// Returns the [`PathBuf`] pointing to the associated configuration file.
pub fn file_path() -> Result<PathBuf> {
Expand Down
11 changes: 8 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! and execution of `cargo install` with the required settings.
use std::collections::{BTreeMap, BTreeSet};
use std::env;
use std::process::ExitCode;

use anyhow::{bail, Result};
#[macro_use]
Expand All @@ -17,9 +18,13 @@ use config::{CargoCratesToml, Package, UserConfig};

/// Wrap the desired main and display errors in a fashion consistent with the
/// rest of the messages.
fn main() {
if let Err(err) = wrapped_main() {
error!("{}", err);
fn main() -> ExitCode {
match wrapped_main() {
Ok(_) => ExitCode::SUCCESS,
Err(err) => {
error!("{}", err);
ExitCode::FAILURE
}
}
}

Expand Down