All Projects → azohra → yaml.sh

azohra / yaml.sh

Licence: MIT license
Read YAML files with only Bash

Programming Languages

shell
77523 projects
CSS
56736 projects
HTML
75241 projects
awk
318 projects
Makefile
30231 projects

Projects that are alternatives of or similar to yaml.sh

dataconf
Simple dataclasses configuration management for Python with hocon/json/yaml/properties/env-vars/dict support.
Stars: ✭ 40 (+33.33%)
Mutual labels:  yaml, parsing
Mini Yaml
Single header YAML 1.0 C++11 serializer/deserializer.
Stars: ✭ 79 (+163.33%)
Mutual labels:  yaml, parsing
python-yamlable
A thin wrapper of PyYaml to convert Python objects to YAML and back
Stars: ✭ 28 (-6.67%)
Mutual labels:  yaml, parsing
Yamerl
YAML 1.2 and JSON parser in pure Erlang
Stars: ✭ 174 (+480%)
Mutual labels:  yaml, parsing
Neon
🍸 Encodes and decodes NEON file format.
Stars: ✭ 674 (+2146.67%)
Mutual labels:  yaml, parsing
Eo Yaml
YAML for Java 8 and above. A user-friendly OOP library. Previously known as "Camel".
Stars: ✭ 189 (+530%)
Mutual labels:  yaml, parsing
postcss-jsx
PostCSS syntax for parsing CSS in JS literals
Stars: ✭ 73 (+143.33%)
Mutual labels:  parsing
cfn-include
Preprocessor for CloudFormation templates with support for loops and flexible include statements
Stars: ✭ 83 (+176.67%)
Mutual labels:  yaml
DotGrok
Parse text with pattern. Inspired by grok filter.
Stars: ✭ 26 (-13.33%)
Mutual labels:  parsing
Cli
A simple, fast, and fun package for building command line apps in Go
Stars: ✭ 16,995 (+56550%)
Mutual labels:  yaml
CV
📜 My Data Driven CV written with R, YAML, & LaTeX
Stars: ✭ 54 (+80%)
Mutual labels:  yaml
scikit-ci
Simpler and centralized CI configuration for Python extensions.
Stars: ✭ 15 (-50%)
Mutual labels:  yaml
quick-csv-streamer
Quick CSV Parser with Java 8 Streams API
Stars: ✭ 29 (-3.33%)
Mutual labels:  parsing
yellowpages-scraper
Yellowpages.com Web Scraper written in Python and LXML to extract business details available based on a particular category and location.
Stars: ✭ 56 (+86.67%)
Mutual labels:  parsing
yaml-update-action
Update YAML property with dynamic values
Stars: ✭ 81 (+170%)
Mutual labels:  yaml
CaptCC
A tiny C compiler written purely in JavaScript.
Stars: ✭ 175 (+483.33%)
Mutual labels:  parsing
yaml-vim
YAML syntax/indent plugin for Vim
Stars: ✭ 37 (+23.33%)
Mutual labels:  yaml
autumn
A Java parser combinator library written with an unmatched feature set.
Stars: ✭ 112 (+273.33%)
Mutual labels:  parsing
ghakuf
A Rust library for parsing/building SMF (Standard MIDI File).
Stars: ✭ 30 (+0%)
Mutual labels:  parsing
apipkgen
Generate an R package from API specs
Stars: ✭ 12 (-60%)
Mutual labels:  yaml

Yaml.sh

Build Status


Yup. A YAML parser completely in bash. I can't believe it either.

At the moment, we support a subset of the yaml spec.

Getting Started

Install it:

$ curl -s https://get.yaml.sh | sh

Then query with it:

$ ysh -f my.yml -q "path.to.awesomeness"

Library use

If installed:

YSH_LIB=1;source /usr/local/bin/ysh

If you want the internet as your only dependency:

$ YSH_LIB=1;source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/azohra/yaml.sh/v0.2.0/ysh)"

Cook Book

---
block_no: 0
level_one:
  level_two:
    key: value
    quoted: "value"
    simple_lists:
      - first
      - second item
      - "third item"
    object_lists:
      - {name: one, value: 1}
      - {name: "second thing", value: 2}
    expanded_lists:
      - name: one
        value: 1
      - name: two
        value: 2
      - name: "quoted thing"
        value: 9000
---
block_no: 1

Read from a file:

ysh -f input.yaml -Q "block_no"

Re-use an already transpiled file

file=$(ysh -f input.yaml)
ysh -T $file -Q "block_no"

Query piped yaml

cat input.yaml | ysh -Q "block_no"

Query for a value

ysh -f file.yaml -Q "block_no"

Query from a stored sub structure

sub=$(ysh -f file.yaml -s "level_one")
ysh -T $sub -Q "level_two.key"

Query i'th item from a simple list

ysh -f input.yaml -Q "level_one.level_two.simple_lists[1]"

Query i'th item from a complex list

ysh -f input.yaml -Q "level_one.level_two.expanded_lists[1].name"

Print value from each block

 #!/bin/bash
YSH_LIB=1; source /usr/local/bin/ysh

file=$(ysh -f input.yaml)
while [ -n "${file}" ]; do
  echo "Block Number:" $(ysh -T "${file}" -Q "block_no")
  file=$(ysh -T "${file}" -n)
done

Flags

TIP: Most flags have an upper-case and lower case usage. Upper case flags denote the expectation of a value (empty otherwise), where lowercase flags are chainable queries that can also be passed back in with -T. In most cases queries will end with an uppercase flag.

-f, --file <file_name>

Read from a file.

-T, --transpiled <file_name>

Read from a pre-transpiled string.

-q, --query <query>

Generic query string. DOES NOT SUPPORT [n] NOTATION

-Q, --query-val <query>

Safe query. Guarentees the return is a value. DOES NOT SUPPORT [n] NOTATION

-s, --sub <query>

Query for a subtree of yaml. Guarentees results are a subtree and no values are returned.

-l, --list <query>

Query for a list.

-L, --list <query>

Query for a list of values. Guarentees results are all values.

-c, --count <query>

Query for a list and count the elements.

-i, --index <i>

Access i'th element from chained list query.

-I, --index-val <i>

Access i'th element from chained list query. Garentees result is a value.

-t, --tops

Return top level keys of structure.

-n, --next

Moves to next block

-h, --help

Show this help dialog.

For more complete usage and examples look at the docs.


Made with ❤️ by the developers at azohra.com

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].