Skip to content

Commit

Permalink
feat: support bsfmt (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Jun 16, 2024
1 parent a338bc2 commit d0181d4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mdsf init
<!-- START_SECTION:supported-languages -->

`mdsf` currently supports 127 tools.
`mdsf` currently supports 128 tools.

| Formatter | Description |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -122,6 +122,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) |
| 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) |
| cabal_format | [https://www.haskell.org/cabal/](https://www.haskell.org/cabal/) |
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.1.1/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@
"type": "string",
"enum": ["bpfmt"]
},
{
"description": "https://github.com/rokucommunity/brighterscript-formatter",
"type": "string",
"enum": ["bsfmt"]
},
{
"description": "https://buf.build/docs/reference/cli/buf/format",
"type": "string",
Expand Down
13 changes: 13 additions & 0 deletions src/formatters/bsfmt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use super::execute_command;
use crate::error::MdsfError;

#[inline]
pub fn format_using_bsfmt(
file_path: &std::path::Path,
) -> Result<(bool, Option<String>), MdsfError> {
let mut cmd = std::process::Command::new("bsfmt");

cmd.arg(file_path).arg("--write");

execute_command(&mut 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 @@ -88,6 +88,7 @@ mod black;
mod blade_formatter;
mod blue;
mod bpfmt;
mod bsfmt;
mod buf;
mod buildifier;
mod cabal_format;
Expand Down Expand Up @@ -376,6 +377,10 @@ pub enum Tooling {
#[serde(rename = "bpfmt")]
Bpfmt,

#[doc = "https://github.com/rokucommunity/brighterscript-formatter"]
#[serde(rename = "bsfmt")]
Bsfmt,

#[doc = "https://buf.build/docs/reference/cli/buf/format"]
#[serde(rename = "buf")]
Buf,
Expand Down Expand Up @@ -852,6 +857,7 @@ impl Tooling {
Self::BladeFormatter => format_using_blade_formatter(snippet_path),
Self::Blue => format_using_blue(snippet_path),
Self::Bpfmt => format_using_bpfmt(snippet_path),
Self::Bsfmt => bsfmt::format_using_bsfmt(snippet_path),
Self::Buf => format_using_buf(snippet_path),
Self::Buildifier => format_using_buildifier(snippet_path),
Self::CSharpier => format_using_csharpier(snippet_path),
Expand Down Expand Up @@ -988,6 +994,7 @@ impl core::fmt::Display for Tooling {
Self::BladeFormatter => write!(f, "blade-formatter"),
Self::Blue => write!(f, "blue"),
Self::Bpfmt => write!(f, "bpfmt"),
Self::Bsfmt => write!(f, "bsfmt"),
Self::Buf => write!(f, "buf"),
Self::Buildifier => write!(f, "buildifier"),
Self::CSharpier => write!(f, "csharpier"),
Expand Down

0 comments on commit d0181d4

Please sign in to comment.