Skip to content

Commit

Permalink
Add support for yq
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Nov 21, 2023
1 parent 615b0f5 commit 5418f26
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ The format is based on [Keep a Changelog].

### Formatters

* [`yq`](https://mikefarah.gitbook.io/yq/) for YAML, JSON, CSV, TSV, XML and [.properties](https://en.wikipedia.org/wiki/.properties) ([#250]).
* [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]).
* [`jq`](https://stedolan.github.io/jq/) for
[JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON)
Expand Down
8 changes: 7 additions & 1 deletion apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@
(stylua . ("stylua" "-"))
(rustfmt . ("rustfmt" "--quiet" "--emit" "stdout"))
(terraform . ("terraform" "fmt" "-"))
(yapf . ("yapf")))
(yapf . ("yapf"))
(yq-csv . ("yq" "--prettyPrint" "--no-colors" "--input-format" "csv" "--output-format" "csv"))
(yq-json . ("yq" "--prettyPrint" "--no-colors" "--input-format" "json" "--output-format" "json"))
(yq-properties . ("yq" "--prettyPrint" "--no-colors" "--input-format" "props" "--output-format" "props"))
(yq-tsv . ("yq" "--prettyPrint" "--no-colors" "--input-format" "tsv" "--output-format" "tsv"))
(yq-xml . ("yq" "--prettyPrint" "--no-colors" "--input-format" "xml" "--output-format" "xml"))
(yq-yaml . ("yq" "--prettyPrint" "--no-colors" "--no-doc" "--input-format" "yaml" "--output-format" "yaml")))
"Alist of code formatting commands.
The keys may be any symbols you want, and the values are shell
commands, lists of strings and symbols, or a function symbol.
Expand Down
1 change: 1 addition & 0 deletions test/formatters/installers/yq-csv.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-json.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-properties.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-tsv.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-xml.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq-yaml.bash
1 change: 1 addition & 0 deletions test/formatters/installers/yq.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -fsSLo /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && chmod +x /usr/local/bin/yq
2 changes: 2 additions & 0 deletions test/formatters/samplecode/yq-csv/in.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello,"world"
a,"1,2"
2 changes: 2 additions & 0 deletions test/formatters/samplecode/yq-csv/out.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello,world
a,"1,2"
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-json/in.json
19 changes: 19 additions & 0 deletions test/formatters/samplecode/yq-json/out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false
}
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-properties/in.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo=bar
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-properties/out.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo = bar
2 changes: 2 additions & 0 deletions test/formatters/samplecode/yq-tsv/in.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello "world"
a "1 2"
2 changes: 2 additions & 0 deletions test/formatters/samplecode/yq-tsv/out.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello world
a "1 2"
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-xml/in.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<hello who='world' />
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-xml/out.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<hello who="world"></hello>
1 change: 1 addition & 0 deletions test/formatters/samplecode/yq-yaml/in.yml
7 changes: 7 additions & 0 deletions test/formatters/samplecode/yq-yaml/out.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- hosts: all
tasks:
- name: Get software for apt repository management.
apt:
state: present
name:
- python3-pycurl

0 comments on commit 5418f26

Please sign in to comment.