Skip to content

Commit

Permalink
fix: do not make files optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jpedroh committed Aug 24, 2024
1 parent b9ecfdb commit 8146c1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bin/src/cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct DiffCliArgs {
pub struct MergeCliArgs {
/// Path to file in base revision
#[arg(short, long)]
pub(crate) base_path: Option<std::path::PathBuf>,
pub(crate) base_path: std::path::PathBuf,

/// Path to file in left revision
#[arg(short, long)]
Expand All @@ -51,7 +51,7 @@ pub struct MergeCliArgs {

/// Path where the merged file should be written
#[arg(short, long)]
pub(crate) merge_path: Option<std::path::PathBuf>,
pub(crate) merge_path: std::path::PathBuf,

/// The language that the files being diffed are written in.
/// If not provided the language will try to be inferred by the extension.
Expand Down
8 changes: 3 additions & 5 deletions bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ fn main() {
}

fn run_merge(args: MergeCliArgs) {
let base_path = args.base_path.unwrap();

let base = std::fs::read_to_string(&base_path).unwrap_or_else(|error| {
let base = std::fs::read_to_string(&args.base_path).unwrap_or_else(|error| {
log::error!("Error while reading base file: {}", error);
std::process::exit(cli_exit_codes::READING_FILE_ERROR)
});
Expand All @@ -37,7 +35,7 @@ fn run_merge(args: MergeCliArgs) {

let language = match args.language {
Some(language) => language::get_language_from_name(&language),
None => language::get_language_by_file_path(&base_path),
None => language::get_language_by_file_path(&args.base_path),
}
.unwrap_or_else(|error| {
log::error!("Error while retrieving language configuration: {}", error);
Expand All @@ -50,7 +48,7 @@ fn run_merge(args: MergeCliArgs) {
std::process::exit(cli_exit_codes::INTERNAL_EXECUTION_ERROR)
});

std::fs::write(args.merge_path.unwrap(), result.to_string()).unwrap_or_else(|error| {
std::fs::write(args.merge_path, result.to_string()).unwrap_or_else(|error| {
log::error!("Error while writing output file: {}", error);
std::process::exit(cli_exit_codes::WRITING_FILE_ERROR)
});
Expand Down

0 comments on commit 8146c1a

Please sign in to comment.