From e49cd0062990c538b13156499823cab6ac75dc80 Mon Sep 17 00:00:00 2001 From: Mads Hougesen Date: Mon, 24 Feb 2025 15:29:43 +0100 Subject: [PATCH] refactor(kulala-fmt): update arguments to v2 --- CHANGELOG.md | 1 + README.md | 7 +++--- .../{kulala_fmt.rs => kulala_fmt_check.rs} | 3 ++- mdsf/src/tools/kulala_fmt_format.rs | 23 +++++++++++++++++ mdsf/src/tools/mod.rs | 25 +++++++++++++------ schemas/v0.5.3-dev/mdsf.schema.json | 9 +++++-- tools/kulala-fmt/plugin.json | 11 +++++--- 7 files changed, 63 insertions(+), 16 deletions(-) rename mdsf/src/tools/{kulala_fmt.rs => kulala_fmt_check.rs} (89%) create mode 100644 mdsf/src/tools/kulala_fmt_format.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 37458690..6e901f01 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.5.2...HEAD) +- refactor(kulala-fmt): update arguments to v2 [`#728`](https://github.com/hougesen/mdsf/pull/728) - fix(cli): simplify file modified check [`#727`](https://github.com/hougesen/mdsf/pull/727) - chore: add package manager to sleek, sqlfmt and typstyle [`#726`](https://github.com/hougesen/mdsf/pull/726) - feat(cli): add support for pasfmt [`#725`](https://github.com/hougesen/mdsf/pull/725) diff --git a/README.md b/README.md index 2941bc2c..7fcb300b 100644 --- a/README.md +++ b/README.md @@ -463,7 +463,7 @@ mdsf init | [kdoc-formatter](https://github.com/tnorbye/kdoc-formatter) | Reformats Kotlin KDoc comments, reflowing text and other cleanup | `formatter` | `kotlin` | | [ktfmt](https://github.com/facebook/ktfmt) | program that reformats Kotlin source code to comply with the common community standard for Kotlin code conventions | `formatter` | `kotlin` | | [ktlint](https://github.com/pinterest/ktlint) | An anti-bikeshedding Kotlin linter with built-in formatter | `linter` | `kotlin` | -| [kulala-fmt](https://github.com/mistweaverco/kulala-fmt) | An opinionated 🦄 .http and .rest 🐼 files linter 💄 and formatter ⚡ | `formatter` | `http` | +| [kulala-fmt](https://github.com/mistweaverco/kulala-fmt) | An opinionated .http and .rest file linter and formatter | `formatter` | `http` | | [leptosfmt](https://github.com/bram209/leptosfmt) | A formatter for the leptos view! macro | `formatter` | `rust` | | [liquidsoap-prettier](https://github.com/savonet/liquidsoap-prettier) | Prettier plugin for liquidsoap script | `formatter` | `liquidsoap` | | [luacheck](https://github.com/lunarmodules/luacheck) | A tool for linting and static analysis of Lua code | `formatter` | `lua` | @@ -609,7 +609,7 @@ mdsf init -`mdsf` currently supports 276 commands. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃 +`mdsf` currently supports 277 commands. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃 | Name | Command | | ------------------------ | --------------------------------------------------------------------------------------- | @@ -741,7 +741,8 @@ mdsf init | `kdoc-formatter` | `kdoc-formatter --quiet $PATH` | | `ktfmt` | `ktfmt --format --log-level=error $PATH` | | `ktlint` | `ktlint --format --log-level=error $PATH` | -| `kulala-fmt` | `kulala-fmt $PATH` | +| `kulala-fmt:check` | `kulala-fmt check $PATH` | +| `kulala-fmt:format` | `kulala-fmt format $PATH` | | `leptosfmt` | `leptosfmt --quiet $PATH` | | `liquidsoap-prettier` | `liquidsoap-prettier --write $PATH` | | `luacheck` | `luacheck $PATH` | diff --git a/mdsf/src/tools/kulala_fmt.rs b/mdsf/src/tools/kulala_fmt_check.rs similarity index 89% rename from mdsf/src/tools/kulala_fmt.rs rename to mdsf/src/tools/kulala_fmt_check.rs index c0e09be3..5f543410 100644 --- a/mdsf/src/tools/kulala_fmt.rs +++ b/mdsf/src/tools/kulala_fmt_check.rs @@ -8,6 +8,7 @@ pub fn set_args( mut cmd: std::process::Command, file_path: &std::path::Path, ) -> std::process::Command { + cmd.arg("check"); cmd.arg(file_path); cmd } @@ -19,4 +20,4 @@ pub const COMMANDS: [CommandType; 3] = [ ]; #[cfg(test)] -mod test_kulala_fmt {} +mod test_kulala_fmt_check {} diff --git a/mdsf/src/tools/kulala_fmt_format.rs b/mdsf/src/tools/kulala_fmt_format.rs new file mode 100644 index 00000000..7f71d597 --- /dev/null +++ b/mdsf/src/tools/kulala_fmt_format.rs @@ -0,0 +1,23 @@ +/// +/// THIS FILE IS GENERATED USING CODE - DO NOT EDIT MANUALLY +/// +use crate::runners::CommandType; + +#[inline] +pub fn set_args( + mut cmd: std::process::Command, + file_path: &std::path::Path, +) -> std::process::Command { + cmd.arg("format"); + cmd.arg(file_path); + cmd +} + +pub const COMMANDS: [CommandType; 3] = [ + CommandType::NodeModules("kulala-fmt"), + CommandType::Direct("kulala-fmt"), + CommandType::Npm("@mistweaverco/kulala-fmt"), +]; + +#[cfg(test)] +mod test_kulala_fmt_format {} diff --git a/mdsf/src/tools/mod.rs b/mdsf/src/tools/mod.rs index 14852446..13e62bd9 100644 --- a/mdsf/src/tools/mod.rs +++ b/mdsf/src/tools/mod.rs @@ -129,7 +129,8 @@ pub mod kdlfmt; pub mod kdoc_formatter; pub mod ktfmt; pub mod ktlint; -pub mod kulala_fmt; +pub mod kulala_fmt_check; +pub mod kulala_fmt_format; pub mod leptosfmt; pub mod liquidsoap_prettier; pub mod luacheck; @@ -1306,13 +1307,21 @@ pub enum Tooling { /// `ktlint --format --log-level=error $PATH` Ktlint, - #[serde(rename = "kulala-fmt")] - /// An opinionated 🦄 .http and .rest 🐼 files linter 💄 and formatter ⚡ + #[serde(rename = "kulala-fmt:check")] + /// Check if .http and .rest code is formatted /// /// [https://github.com/mistweaverco/kulala-fmt](https://github.com/mistweaverco/kulala-fmt) /// - /// `kulala-fmt $PATH` - KulalaFmt, + /// `kulala-fmt check $PATH` + KulalaFmtCheck, + + #[serde(rename = "kulala-fmt:format")] + /// Format .http and .rest code + /// + /// [https://github.com/mistweaverco/kulala-fmt](https://github.com/mistweaverco/kulala-fmt) + /// + /// `kulala-fmt format $PATH` + KulalaFmtFormat, #[serde(rename = "leptosfmt")] /// A formatter for the leptos view! macro @@ -2637,7 +2646,8 @@ impl Tooling { Self::KdocFormatter => (&kdoc_formatter::COMMANDS, kdoc_formatter::set_args), Self::Ktfmt => (&ktfmt::COMMANDS, ktfmt::set_args), Self::Ktlint => (&ktlint::COMMANDS, ktlint::set_args), - Self::KulalaFmt => (&kulala_fmt::COMMANDS, kulala_fmt::set_args), + Self::KulalaFmtCheck => (&kulala_fmt_check::COMMANDS, kulala_fmt_check::set_args), + Self::KulalaFmtFormat => (&kulala_fmt_format::COMMANDS, kulala_fmt_format::set_args), Self::Leptosfmt => (&leptosfmt::COMMANDS, leptosfmt::set_args), Self::LiquidsoapPrettier => ( &liquidsoap_prettier::COMMANDS, @@ -2930,7 +2940,8 @@ impl AsRef for Tooling { Self::KdocFormatter => "kdoc_formatter", Self::Ktfmt => "ktfmt", Self::Ktlint => "ktlint", - Self::KulalaFmt => "kulala_fmt", + Self::KulalaFmtCheck => "kulala_fmt_check", + Self::KulalaFmtFormat => "kulala_fmt_format", Self::Leptosfmt => "leptosfmt", Self::LiquidsoapPrettier => "liquidsoap_prettier", Self::Luacheck => "luacheck", diff --git a/schemas/v0.5.3-dev/mdsf.schema.json b/schemas/v0.5.3-dev/mdsf.schema.json index a98e48fe..cd964afc 100644 --- a/schemas/v0.5.3-dev/mdsf.schema.json +++ b/schemas/v0.5.3-dev/mdsf.schema.json @@ -707,9 +707,14 @@ "enum": ["ktlint"] }, { - "description": "An opinionated 🦄 .http and .rest 🐼 files linter 💄 and formatter ⚡\n\n[https://github.com/mistweaverco/kulala-fmt](https://github.com/mistweaverco/kulala-fmt)\n\n`kulala-fmt $PATH`", + "description": "Check if .http and .rest code is formatted\n\n[https://github.com/mistweaverco/kulala-fmt](https://github.com/mistweaverco/kulala-fmt)\n\n`kulala-fmt check $PATH`", "type": "string", - "enum": ["kulala-fmt"] + "enum": ["kulala-fmt:check"] + }, + { + "description": "Format .http and .rest code\n\n[https://github.com/mistweaverco/kulala-fmt](https://github.com/mistweaverco/kulala-fmt)\n\n`kulala-fmt format $PATH`", + "type": "string", + "enum": ["kulala-fmt:format"] }, { "description": "A formatter for the leptos view! macro\n\n[https://github.com/bram209/leptosfmt](https://github.com/bram209/leptosfmt)\n\n`leptosfmt --quiet $PATH`", diff --git a/tools/kulala-fmt/plugin.json b/tools/kulala-fmt/plugin.json index 06487b36..97ef4d9c 100644 --- a/tools/kulala-fmt/plugin.json +++ b/tools/kulala-fmt/plugin.json @@ -3,11 +3,16 @@ "binary": "kulala-fmt", "categories": ["formatter"], "commands": { - "": { - "arguments": ["$PATH"] + "check": { + "arguments": ["check", "$PATH"], + "description": "Check if .http and .rest code is formatted" + }, + "format": { + "arguments": ["format", "$PATH"], + "description": "Format .http and .rest code" } }, - "description": "An opinionated 🦄 .http and .rest 🐼 files linter 💄 and formatter ⚡", + "description": "An opinionated .http and .rest file linter and formatter", "homepage": "https://github.com/mistweaverco/kulala-fmt", "languages": ["http"], "packages": {