Skip to content

Commit

Permalink
feat(veryl): support veryl fmt (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Jun 20, 2024
1 parent 7dfcc09 commit 83a8805
Show file tree
Hide file tree
Showing 4 changed files with 25 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 141 tools.
`mdsf` currently supports 142 tools.

| Formatter | Description |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -240,6 +240,7 @@ mdsf init
| typos | [/~https://github.com/crate-ci/typos](/~https://github.com/crate-ci/typos) |
| uiua_fmt | [/~https://github.com/uiua-lang/uiua](/~https://github.com/uiua-lang/uiua) |
| usort | [/~https://github.com/facebook/usort](/~https://github.com/facebook/usort) |
| veryl_fmt | [/~https://github.com/veryl-lang/veryl](/~https://github.com/veryl-lang/veryl) |
| xmlformat | [/~https://github.com/pamoller/xmlformatter](/~https://github.com/pamoller/xmlformatter) |
| xmllint | [http://xmlsoft.org/xmllint.html](http://xmlsoft.org/xmllint.html) |
| xo | [http://github.com/xojs/xo](http://github.com/xojs/xo) |
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.1.2/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,11 @@
"type": "string",
"enum": ["usort"]
},
{
"description": "/~https://github.com/veryl-lang/veryl",
"type": "string",
"enum": ["veryl_fmt"]
},
{
"description": "/~https://github.com/pamoller/xmlformatter",
"type": "string",
Expand Down
7 changes: 7 additions & 0 deletions src/formatters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ mod ts_standard;
mod typos;
mod uiua;
mod usort;
mod veryl;
mod xmlformat;
mod xmllint;
mod xo;
Expand Down Expand Up @@ -796,6 +797,10 @@ pub enum Tooling {
#[serde(rename = "usort")]
Usort,

#[doc = "/~https://github.com/veryl-lang/veryl"]
#[serde(rename = "veryl_fmt")]
VerylFmt,

#[doc = "/~https://github.com/pamoller/xmlformatter"]
#[serde(rename = "xmlformat")]
XmlFormat,
Expand Down Expand Up @@ -973,6 +978,7 @@ impl Tooling {
Self::Typos => typos::run(snippet_path),
Self::UiuaFmt => uiua::run_fmt(snippet_path),
Self::Usort => usort::run(snippet_path),
Self::VerylFmt => veryl::run_fmt(snippet_path),
Self::XmlFormat => xmlformat::run(snippet_path),
Self::XmlLint => xmllint::run(snippet_path),
Self::Xo => xo::run(snippet_path),
Expand Down Expand Up @@ -1123,6 +1129,7 @@ impl core::fmt::Display for Tooling {
Self::Typos => write!(f, "typos"),
Self::UiuaFmt => write!(f, "uiua_fmt"),
Self::Usort => write!(f, "usort"),
Self::VerylFmt => write!(f, "veryl_fmt"),
Self::XmlFormat => write!(f, "xmlformat"),
Self::XmlLint => write!(f, "xmllint"),
Self::Xo => write!(f, "xo"),
Expand Down
11 changes: 11 additions & 0 deletions src/formatters/veryl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use super::execute_command;
use crate::error::MdsfError;

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

cmd.arg("fmt").arg(file_path);

execute_command(&mut cmd, file_path)
}

0 comments on commit 83a8805

Please sign in to comment.