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

feat: support brittany #352

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ mdsf init

<!-- START_SECTION:supported-tools -->

`mdsf` currently supports 162 tools.
`mdsf` currently supports 163 tools.

| Formatter | Description |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -215,6 +215,7 @@ mdsf init
| blade-formatter | [https://github.com/shufo/blade-formatter](https://github.com/shufo/blade-formatter) |
| blue | [https://blue.readthedocs.io/en/latest/](https://blue.readthedocs.io/en/latest/) |
| bpfmt | [https://source.android.com/docs/setup/reference/androidbp](https://source.android.com/docs/setup/reference/androidbp) |
| brittany | [https://github.com/lspitzner/brittany](https://github.com/lspitzner/brittany) |
| bsfmt | [https://github.com/rokucommunity/brighterscript-formatter](https://github.com/rokucommunity/brighterscript-formatter) |
| buf | [https://buf.build/docs/reference/cli/buf/format](https://buf.build/docs/reference/cli/buf/format) |
| buildifier | [https://github.com/bazelbuild/buildtools](https://github.com/bazelbuild/buildtools) |
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.2.1/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@
"type": "string",
"enum": ["buildifier"]
},
{
"description": "https://github.com/lspitzner/brittany",
"type": "string",
"enum": ["brittany"]
},
{
"description": "https://www.haskell.org/cabal/",
"type": "string",
Expand Down
11 changes: 11 additions & 0 deletions src/formatters/brittany.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use super::execute_command;
use crate::{error::MdsfError, runners::CommandType};

#[inline]
pub fn run(file_path: &std::path::Path) -> Result<(bool, Option<String>), MdsfError> {
let mut cmd = CommandType::Direct("brittany").build();

cmd.arg("--write-mode=inplace").arg(file_path);

execute_command(cmd, file_path)
}
7 changes: 7 additions & 0 deletions src/formatters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mod black;
mod blade_formatter;
mod blue;
mod bpfmt;
mod brittany;
mod bsfmt;
mod buf;
mod buildifier;
Expand Down Expand Up @@ -402,6 +403,10 @@ pub enum Tooling {
#[serde(rename = "buildifier")]
Buildifier,

#[doc = "https://github.com/lspitzner/brittany"]
#[serde(rename = "brittany")]
Brittany,

#[doc = "https://www.haskell.org/cabal/"]
#[serde(rename = "cabal_format")]
CabalFormat,
Expand Down Expand Up @@ -1000,6 +1005,7 @@ impl Tooling {
Self::Bsfmt => bsfmt::run(snippet_path),
Self::Buf => buf::run(snippet_path),
Self::Buildifier => buildifier::run(snippet_path),
Self::Brittany => brittany::run(snippet_path),
Self::CSharpier => csharpier::run(snippet_path),
Self::CabalFormat => cabal_format::run(snippet_path),
Self::CaramelFmt => caramel::run_fmt(snippet_path),
Expand Down Expand Up @@ -1171,6 +1177,7 @@ impl AsRef<str> for Tooling {
Self::Bsfmt => "bsfmt",
Self::Buf => "buf",
Self::Buildifier => "buildifier",
Self::Brittany => "brittany",
Self::CSharpier => "csharpier",
Self::CabalFormat => "cabal_format",
Self::CaramelFmt => "caramel_fmt",
Expand Down
Loading