Skip to content

Commit

Permalink
Add --path to forc fmt. (FuelLabs#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
adlerjohn authored Apr 24, 2022
1 parent a48a7e9 commit 87b734c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion forc-fmt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use clap::Parser;
use forc_util::{find_manifest_dir, println_green, println_red};
use prettydiff::{basic::DiffOp, diff_lines};
use std::default::Default;
use std::path::PathBuf;
use std::{fs, path::Path, sync::Arc};
use sway_core::BuildConfig;
use sway_fmt::{get_formatted_data, FormattingOptions};
Expand All @@ -24,11 +25,17 @@ pub struct App {
/// - Exits with `1` and prints a diff if formatting is required.
#[clap(short, long)]
pub check: bool,
/// Path to the project, if not specified, current working directory will be used.
#[clap(short, long)]
pub path: Option<String>,
}

fn main() -> Result<()> {
let app = App::parse();
let dir = std::env::current_dir()?;
let dir = match app.path.clone() {
Some(p) => PathBuf::from(p),
None => std::env::current_dir()?,
};
format_pkg_at_dir(app, &dir)
}

Expand Down

0 comments on commit 87b734c

Please sign in to comment.