Skip to content

Commit

Permalink
fix(doc): generate in custom path and check if amber file exist (#465)
Browse files Browse the repository at this point in the history
* fix(doc): generate in custom path and check if amber file exist

* fix(doc): generate in custom path and check if amber file exist

* fix(doc): generate in custom path and check if amber file exist

* fix(doc): add breakline

* fix(doc): add breakline

* fix(review): done

* fix(review): removed code

* fix(review): imprroved code
  • Loading branch information
Mte90 authored Sep 19, 2024
1 parent 59ab59a commit 9f76525
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use heraclitus_compiler::prelude::*;
use std::error::Error;
use std::fs;
use std::io::{prelude::*, stdin};
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::process::Command;

#[derive(Parser, Clone, Debug)]
Expand All @@ -33,7 +33,7 @@ pub struct Cli {
eval: Option<String>,

/// Generate docs
/// (OUTPUT is dir instead, default: `docs/`)
/// (OUTPUT is dir instead, default: `docs/` if missing it will generate the folder)
#[arg(long)]
docs: bool,

Expand Down Expand Up @@ -136,6 +136,14 @@ fn handle_eval(code: String, cli: Cli) -> Result<(), Box<dyn Error>> {

fn handle_docs(cli: Cli) -> Result<(), Box<dyn Error>> {
let input = if let Some(ref input) = cli.input {
let path = Path::new(input);
if !path.exists() {
Message::new_err_msg(format!(
"Amber file doesn't exist: `{}`.", input.to_string_lossy()
))
.show();
std::process::exit(1);
}
String::from(input.to_string_lossy())
} else {
Message::new_err_msg(
Expand Down

0 comments on commit 9f76525

Please sign in to comment.