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 djade #520

Merged
merged 1 commit into from
Oct 27, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 djade [`#520`](https://github.com/hougesen/mdsf/pull/520)
- feat: support tsqllint [`#519`](https://github.com/hougesen/mdsf/pull/519)
- feat: support pyment [`#518`](https://github.com/hougesen/mdsf/pull/518)
- feat: support sqruff [`#517`](https://github.com/hougesen/mdsf/pull/517)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ mdsf init

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

`mdsf` currently supports 210 commands. Feel free to open an issue/pull-request if your favorite tool is missing! 😃
`mdsf` currently supports 211 commands. Feel free to open an issue/pull-request if your favorite tool is missing! 😃

| Name | Command |
| ------------------------ | -------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -237,6 +237,7 @@ mdsf init
| `deno:lint` | `deno lint --fix PATH` |
| `dfmt` | `dfmt -i PATH` |
| `dhall` | `dhall format PATH` |
| `djade` | `djade PATH` |
| `djlint` | `djlint PATH --reformat` |
| `docformatter` | `docformatter --in-place PATH` |
| `docstrfmt` | `docstrfmt PATH` |
Expand Down
34 changes: 34 additions & 0 deletions mdsf/src/tools/djade.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::process::Command;

use crate::{error::MdsfError, execution::execute_command, runners::CommandType};

#[inline]
fn set_djade_args(mut cmd: Command, file_path: &std::path::Path) -> Command {
cmd.arg(file_path);
cmd
}

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

for (index, cmd) in commands.iter().enumerate() {
let cmd = set_djade_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_djade {}
7 changes: 7 additions & 0 deletions mdsf/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub mod deno_fmt;
pub mod deno_lint;
pub mod dfmt;
pub mod dhall;
pub mod djade;
pub mod djlint;
pub mod docformatter;
pub mod docstrfmt;
Expand Down Expand Up @@ -409,6 +410,10 @@ pub enum Tooling {
/// `dhall format $PATH`
Dhall,

#[serde(rename = "djade")]
/// `djade $PATH`
Djade,

#[serde(rename = "djlint")]
/// `djlint $PATH --reformat`
Djlint,
Expand Down Expand Up @@ -1111,6 +1116,7 @@ impl Tooling {
Self::DenoLint => deno_lint::run(snippet_path),
Self::Dfmt => dfmt::run(snippet_path),
Self::Dhall => dhall::run(snippet_path),
Self::Djade => djade::run(snippet_path),
Self::Djlint => djlint::run(snippet_path),
Self::Docformatter => docformatter::run(snippet_path),
Self::Docstrfmt => docstrfmt::run(snippet_path),
Expand Down Expand Up @@ -1330,6 +1336,7 @@ impl AsRef<str> for Tooling {
Self::DenoLint => "deno_lint",
Self::Dfmt => "dfmt",
Self::Dhall => "dhall",
Self::Djade => "djade",
Self::Djlint => "djlint",
Self::Docformatter => "docformatter",
Self::Docstrfmt => "docstrfmt",
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.2.7/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@
"type": "string",
"enum": ["dhall"]
},
{
"description": "`djade $PATH`",
"type": "string",
"enum": ["djade"]
},
{
"description": "`djlint $PATH --reformat`",
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions tools/djade/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../tool.schema.json",
"binary": "djade",
"categories": ["formatter"],
"commands": {
"": ["$PATH"]
},
"description": "A Django template formatter",
"homepage": "https://github.com/adamchainz/djade",
"languages": ["python", "django"],
"name": null,
"npm": null,
"php": null,
"tests": []
}
Loading