diff --git a/CHANGELOG.md b/CHANGELOG.md index edf6ab9..5b09749 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### [Unreleased](https://github.com/hougesen/mdsf/compare/v0.2.7...HEAD) +- feat: support pyment [`#518`](https://github.com/hougesen/mdsf/pull/518) - feat: support sqruff [`#517`](https://github.com/hougesen/mdsf/pull/517) - feat: support opa fmt [`#516`](https://github.com/hougesen/mdsf/pull/516) - feat: support purty [`#515`](https://github.com/hougesen/mdsf/pull/515) diff --git a/README.md b/README.md index d22b272..7bedc2e 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ mdsf init -`mdsf` currently supports 208 commands. Feel free to open an issue/pull-request if your favorite tool is missing! 😃 +`mdsf` currently supports 209 commands. Feel free to open an issue/pull-request if your favorite tool is missing! 😃 | Name | Command | | ------------------------ | -------------------------------------------------------------------------------------- | @@ -330,6 +330,7 @@ mdsf init | `purty` | `purty --write PATH` | | `pycln` | `pycln --no-gitignore --quiet PATH` | | `pyink` | `pyink --quiet PATH` | +| `pyment` | `pyment -w PATH` | | `qmlfmt` | `qmlfmt -w PATH` | | `raco:fmt` | `raco fmt -i PATH` | | `refmt` | `refmt --in-place PATH` | diff --git a/mdsf/src/tools/mod.rs b/mdsf/src/tools/mod.rs index a0499bb..ce444ff 100644 --- a/mdsf/src/tools/mod.rs +++ b/mdsf/src/tools/mod.rs @@ -140,6 +140,7 @@ pub mod purs_tidy; pub mod purty; pub mod pycln; pub mod pyink; +pub mod pyment; pub mod qmlfmt; pub mod raco_fmt; pub mod refmt; @@ -779,6 +780,10 @@ pub enum Tooling { /// `pyink --quiet $PATH` Pyink, + #[serde(rename = "pyment")] + /// `pyment -w $PATH` + Pyment, + #[serde(rename = "qmlfmt")] /// `qmlfmt -w $PATH` Qmlfmt, @@ -1194,6 +1199,7 @@ impl Tooling { Self::Purty => purty::run(snippet_path), Self::Pycln => pycln::run(snippet_path), Self::Pyink => pyink::run(snippet_path), + Self::Pyment => pyment::run(snippet_path), Self::Qmlfmt => qmlfmt::run(snippet_path), Self::RacoFmt => raco_fmt::run(snippet_path), Self::Refmt => refmt::run(snippet_path), @@ -1411,6 +1417,7 @@ impl AsRef for Tooling { Self::Purty => "purty", Self::Pycln => "pycln", Self::Pyink => "pyink", + Self::Pyment => "pyment", Self::Qmlfmt => "qmlfmt", Self::RacoFmt => "raco_fmt", Self::Refmt => "refmt", diff --git a/mdsf/src/tools/pyment.rs b/mdsf/src/tools/pyment.rs new file mode 100644 index 0000000..6b19eab --- /dev/null +++ b/mdsf/src/tools/pyment.rs @@ -0,0 +1,35 @@ +use std::process::Command; + +use crate::{error::MdsfError, execution::execute_command, runners::CommandType}; + +#[inline] +fn set_pyment_args(mut cmd: Command, file_path: &std::path::Path) -> Command { + cmd.arg("-w"); + cmd.arg(file_path); + cmd +} + +#[inline] +pub fn run(file_path: &std::path::Path) -> Result<(bool, Option), MdsfError> { + let commands = [CommandType::Direct("pyment")]; + + for (index, cmd) in commands.iter().enumerate() { + let cmd = set_pyment_args(cmd.build(), file_path); + let execution_result = execute_command(cmd, file_path); + + if index == commands.len() - 1 { + return execution_result; + } + + if let Ok(r) = execution_result { + if !r.0 { + return Ok(r); + } + } + } + + Ok((true, None)) +} + +#[cfg(test)] +mod test_pyment {} diff --git a/schemas/v0.2.7/mdsf.schema.json b/schemas/v0.2.7/mdsf.schema.json index ca35094..b82eb4a 100644 --- a/schemas/v0.2.7/mdsf.schema.json +++ b/schemas/v0.2.7/mdsf.schema.json @@ -768,6 +768,11 @@ "type": "string", "enum": ["pyink"] }, + { + "description": "`pyment -w $PATH`", + "type": "string", + "enum": ["pyment"] + }, { "description": "`qmlfmt -w $PATH`", "type": "string", diff --git a/tools/pyment/plugin.json b/tools/pyment/plugin.json new file mode 100644 index 0000000..d2963a4 --- /dev/null +++ b/tools/pyment/plugin.json @@ -0,0 +1,15 @@ +{ + "$schema": "../tool.schema.json", + "binary": "pyment", + "categories": ["formatter"], + "commands": { + "": ["-w", "$PATH"] + }, + "description": "Format and convert Python docstrings and generates patches", + "homepage": "https://github.com/dadadel/pyment", + "languages": ["python"], + "name": null, + "npm": null, + "php": null, + "tests": [] +}