Stephen McQuay 4 years ago
commit
7ab5bcbe4a
3 changed files with 52 additions and 0 deletions
  1. 14
    0
      LICENSE
  2. 34
    0
      main.go
  3. 4
    0
      readme.md

+ 14
- 0
LICENSE View File

@@ -0,0 +1,14 @@
1
+            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+                    Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+  0. You just DO WHAT THE FUCK YOU WANT TO.
14
+

+ 34
- 0
main.go View File

@@ -0,0 +1,34 @@
1
+package main
2
+
3
+import (
4
+	"bytes"
5
+	"fmt"
6
+	"io"
7
+	"io/ioutil"
8
+	"log"
9
+	"os"
10
+
11
+	"gopkg.in/yaml.v2"
12
+)
13
+
14
+func main() {
15
+	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
16
+	b, err := ioutil.ReadAll(os.Stdin)
17
+	if err != nil {
18
+		fmt.Fprintf(os.Stderr, "problem reading stdin: %v\n", err)
19
+		os.Exit(1)
20
+	}
21
+	var obj interface{}
22
+	err = yaml.Unmarshal(b, &obj)
23
+	if err != nil {
24
+		fmt.Fprintf(os.Stderr, "issue in decoding: %v\n", err)
25
+		os.Exit(1)
26
+	}
27
+	bs, err := yaml.Marshal(obj)
28
+	if err != nil {
29
+		fmt.Fprintf(os.Stderr, "issue in encoding: %v\n", err)
30
+		os.Exit(1)
31
+	}
32
+	r := bytes.NewReader(bs)
33
+	io.Copy(os.Stdout, r)
34
+}

+ 4
- 0
readme.md View File

@@ -0,0 +1,4 @@
1
+jsoon
2
+=====
3
+
4
+Simple lint check for yaml files in the spirit of `python -mjson.tool`.

Loading…
Cancel
Save