Add YAML inspector
This commit is contained in:
parent
199fd46b5e
commit
5484db4f74
2 changed files with 30 additions and 1 deletions
|
|
@ -266,7 +266,7 @@ $ examples/which.clj rg
|
|||
### pom.xml version
|
||||
|
||||
A script to retrieve the version from a `pom.xml` file. See
|
||||
[examples/pom_version.clj](../examples/pom_version.clj). Written by [@wilkerlucio](https://github.com/wilkerlucio).
|
||||
[examples/get_pom_version.clj](../examples/get_pom_version.clj). Written by [@wilkerlucio](https://github.com/wilkerlucio).
|
||||
|
||||
### Whatsapp frequencies
|
||||
|
||||
|
|
@ -311,3 +311,9 @@ META-INF/leiningen/borkdude/sci/project.clj
|
|||
### Invoke vim inside a script
|
||||
|
||||
See [examples/vim.clj](../examples/vim.clj).
|
||||
|
||||
### YAML inspector
|
||||
|
||||
This script uses [djblue/portal](https://github.com/djblue/portal/) for viewing a YAML file piped to stdin.
|
||||
|
||||
See [examples/yaml_inspector.clj](../examples/yaml_inspector.clj).
|
||||
|
|
|
|||
23
examples/yaml_inspector.clj
Executable file
23
examples/yaml_inspector.clj
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bb
|
||||
|
||||
(ns yaml-inspector
|
||||
(:require [babashka.classpath :as cp]
|
||||
[clj-yaml.core :as yaml]
|
||||
[clojure.java.shell :refer [sh]]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(def cp (str/trim (:out (sh "clojure" "-Spath" "-Sdeps" "{:deps {djblue/portal {:mvn/version \"0.6.1\"}}}"))))
|
||||
(cp/add-classpath cp)
|
||||
|
||||
(require '[portal.api :as p])
|
||||
(p/open)
|
||||
(p/tap)
|
||||
|
||||
(def yaml (yaml/parse-string (slurp *in*)))
|
||||
(tap> yaml)
|
||||
|
||||
(.addShutdownHook (Runtime/getRuntime)
|
||||
(Thread. (fn [] (p/close))))
|
||||
|
||||
@(promise)
|
||||
|
||||
Loading…
Reference in a new issue