Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xbcsmith/ymlfxr
Rust CLI for formating yaml so it passes stock yamllint
https://github.com/xbcsmith/ymlfxr
rust yaml
Last synced: about 2 months ago
JSON representation
Rust CLI for formating yaml so it passes stock yamllint
- Host: GitHub
- URL: https://github.com/xbcsmith/ymlfxr
- Owner: xbcsmith
- License: apache-2.0
- Created: 2020-04-28T13:47:04.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T21:20:31.000Z (11 months ago)
- Last Synced: 2024-12-10T06:46:57.871Z (2 months ago)
- Topics: rust, yaml
- Language: Rust
- Homepage:
- Size: 20.5 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ymlfxr
## description
rust cli for formatting yaml v1.2 that passes yamllint
with default settings## build
```bash
cargo build --release
```## usage
```bash
Parses an input yaml and output v1.2 yaml file
usage:
ymlfxr bad.yaml > good.yamlUSAGE:
ymlfxr [FLAGS]FLAGS:
-b, --bak Create backup of file
-d, --debug turn on debugging information
-h, --help Prints help information
-i, --fix Fix the file in place
-V, --version Prints version informationARGS:
Sets the input file to use
```## examples
```bash
ymlfxr ./tests/bad.yaml > ./tests/good.yamlymlfxr --fix ./tests/inplace.yaml
ymlfxr --bak --fix ./tests/inplace_w_bak.yaml
```## test
functional tests require `yamllint`
```bash
./testdata/functests.sh
```testing using cargo
```bash
cargo run ./testdata/bad.yaml
```output:
```bash
Updating crates.io index
Compiling libc v0.2.69
Compiling bitflags v1.2.1
Compiling unicode-width v0.1.7
Compiling vec_map v0.8.1
Compiling linked-hash-map v0.5.2
Compiling strsim v0.8.0
Compiling ansi_term v0.11.0
Compiling textwrap v0.11.0
Compiling yaml-rust v0.4.3
Compiling atty v0.2.14
Compiling clap v2.33.0
Compiling ymlfxr v0.1.0 (/Users/bcsmit/go/src/github.com/xbcsmith/ymlfxr)
Finished dev [unoptimized + debuginfo] target(s) in 10.32s
Running `target/debug/ymlfxr bad.yaml`
---
name: foo
version: 0.1.0
release: ~
description: The foo package
summary: foo is the foo
requires:
- bar
- caz
provides:
- foo
instructions:
- unpack: tar -xvf foo-0.1.0.tar.xz && cd sharutils-0.1.0
pre: "sed -i 's/bar/foo/g' Makefile.in"
configure: "./configure --prefix=/usr"
build: make
test: make check
install: make install
post: ""
sources:
- archive: foo-0.1.0.tar.xz
md5: d3b07384d113edec49eaa6238ad5ff00
sha256: b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
destination: /usr
``````bash
yamllint ./testdata/bad.yaml
```output:
```bash
bad.yaml
1:1 warning missing document start "---" (document-start)
7:1 error wrong indentation: expected 2 but found 0 (indentation)
10:1 error wrong indentation: expected 2 but found 0 (indentation)
12:1 error wrong indentation: expected 2 but found 0 (indentation)
20:1 error wrong indentation: expected 2 but found 0 (indentation)
``````bash
cargo run ./testdata/bad.yaml > good.yaml
``````bash
yamllint good.yaml
```no output!