Skip to content

Commit

Permalink
feat: get path as argument (#3)
Browse files Browse the repository at this point in the history
* feat: parse path from args

* feat: format directory

* refactor: flatten dir entries
  • Loading branch information
hougesen authored Mar 5, 2024
1 parent 871f3ec commit a703b9e
Show file tree
Hide file tree
Showing 6 changed files with 400 additions and 4 deletions.
289 changes: 289 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ readme = "README.md"
categories = ["development-tools"]

[dependencies]
clap = { version = "4.5.1", features = ["derive"] }
ignore = "0.4.22"
markdown = "0.3.0"
tempfile = "3.10.1"
21 changes: 21 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use clap::{Args, Parser, Subcommand};

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}

#[derive(Subcommand, Debug)]
pub enum Commands {
Format(FormatCommandArguments),
}

/// Run formatters on input files
#[derive(Args, Debug)]
pub struct FormatCommandArguments {
#[arg()]
pub path: std::path::PathBuf,
}
2 changes: 1 addition & 1 deletion src/formatters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn format_snippet(language: &str, code: String) -> String {
code
}
.trim()
.to_string();
.to_owned();

f.push('\n');

Expand Down
Loading

0 comments on commit a703b9e

Please sign in to comment.