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

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

Merged
merged 8 commits into from
Sep 19, 2024
Merged
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)
Mte90 marked this conversation as resolved.
Show resolved Hide resolved
#[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