Skip to content

Commit

Permalink
feat: support dcm (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Jun 15, 2024
1 parent 7d7e7f7 commit a338bc2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
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 126 tools.
`mdsf` currently supports 127 tools.

| Formatter | Description |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -134,6 +134,7 @@ mdsf init
| csharpier | [https://csharpier.com/](https://csharpier.com/) |
| d2 | [https://d2lang.com/](https://d2lang.com/) |
| dart_format | [https://dart.dev/tools/dart-format](https://dart.dev/tools/dart-format) |
| dcm | [https://dcm.dev](https://dcm.dev) |
| deno_fmt | [https://dart.dev/tools/dart-format](https://dart.dev/tools/dart-format) |
| dfmt | [https://github.com/dlang-community/dfmt](https://github.com/dlang-community/dfmt) |
| djlint | [https://www.djlint.com/](https://www.djlint.com/) |
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 @@ -179,6 +179,11 @@
"type": "string",
"enum": ["dart_format"]
},
{
"description": "https://dcm.dev",
"type": "string",
"enum": ["dcm"]
},
{
"description": "https://dart.dev/tools/dart-format",
"type": "string",
Expand Down
11 changes: 11 additions & 0 deletions src/formatters/dcm.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 format_using_dcm(file_path: &std::path::Path) -> Result<(bool, Option<String>), MdsfError> {
let mut cmd = std::process::Command::new("dcm");

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

execute_command(&mut cmd, file_path)
}
11 changes: 9 additions & 2 deletions src/formatters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use crate::{
cljstyle::format_using_cljstyle, codespell::format_using_codespell,
crlfmt::format_using_crlfmt, crystal_format::format_using_crystal_format,
csharpier::format_using_csharpier, d2::format_using_d2,
dart_format::format_using_dart_format, deno_fmt::format_using_deno_fmt,
dfmt::format_using_dfmt, djlint::format_using_djlint,
dart_format::format_using_dart_format, dcm::format_using_dcm,
deno_fmt::format_using_deno_fmt, dfmt::format_using_dfmt, djlint::format_using_djlint,
docformatter::format_using_docformatter, docstrfmt::format_using_docstrfmt,
dprint::format_using_dprint, efmt::format_using_efmt, elm_format::format_using_elm_format,
erb_formatter::format_using_erb_formatter, erlfmt::format_using_erlfmt,
Expand Down Expand Up @@ -100,6 +100,7 @@ mod crystal_format;
mod csharpier;
mod d2;
mod dart_format;
mod dcm;
mod deno_fmt;
mod dfmt;
mod djlint;
Expand Down Expand Up @@ -423,6 +424,10 @@ pub enum Tooling {
#[serde(rename = "dart_format")]
DartFormat,

#[doc = "https://dcm.dev"]
#[serde(rename = "dcm")]
Dcm,

#[doc = "https://dart.dev/tools/dart-format"]
#[serde(rename = "deno_fmt")]
DenoFmt,
Expand Down Expand Up @@ -860,6 +865,7 @@ impl Tooling {
Self::D2 => format_using_d2(snippet_path),
Self::DFmt => format_using_dfmt(snippet_path),
Self::DartFormat => format_using_dart_format(snippet_path),
Self::Dcm => format_using_dcm(snippet_path),
Self::DenoFmt => format_using_deno_fmt(snippet_path),
Self::DjLint => format_using_djlint(snippet_path),
Self::Docformatter => format_using_docformatter(snippet_path),
Expand Down Expand Up @@ -997,6 +1003,7 @@ impl core::fmt::Display for Tooling {
Self::DartFormat => write!(f, "dart_format"),
Self::DenoFmt => write!(f, "deno_fmt"),
Self::DjLint => write!(f, "djlint"),
Self::Dcm => write!(f, "dcm"),
Self::Docformatter => write!(f, "docformatter"),
Self::Docstrfmt => write!(f, "docstrfmt"),
Self::Dprint => write!(f, "dprint"),
Expand Down

0 comments on commit a338bc2

Please sign in to comment.