#search-query #yaml #query #command-line-tool #tool #file-search #find

app yquery

yquery is a yaml-query command-line utility based on the idea of jquery

2 releases

0.1.1 Jan 3, 2022
0.1.0 Jan 3, 2022

#2413 in Command line utilities

GPL-3.0 license

14KB
323 lines

yquery

Build status crates.io

yquery is a program which finds elements in your yaml documents using selectors. Sort of like how jquery works for css.

Table of Contents

Features

yquery is a command-line tool which currently accepts one file and a 'search query'. It will then search through the document looking for elements of the document which adhere to the search query. I am currently working on multi-file support so you can search directories as well.

Examples

A 'search query' consists of three parts: A element name, a child specifier and id selection. It is given in the form ElementA[childname=name].id. You can have multiple occurrences of each part: (ElementA|ElementB)[childname=name,childage=age].(id,name). If only the element name part is given, the output will the entire element found, as seen in the first example below. If the id selection part is specified, you will only receive those specifically, as seen in the second example below.

Example with no id specifier

[mads@Adria][~/projects/yquery]% yquery documents/verify_apache.yaml "service"
service: { name: httpd, state: started}
service: { name: httpd, state: restarted}

Example with id specifier set

[mads@Adria][~/projects/yquery]% yquery documents/verify_apache.yaml "service.name"
httpd
httpd

Installation

Currently yquery does not reside in any package manager that I know of. So in order to install it you need to build the tool yourself.

Building

You can also build and install from source (requires the latest stable Rust compiler.)

cargo install --git https://github.com/madsravn/yquery.git yquery

Common Issues

Some issues can arise from the grammar I made to parse the search query. If you are in doubt whether or not your query was understood correctly, run the program with a third parameter. Then it will output how it understands your search query.

This tool and its source is licensed under GNU GPLv3

Dependencies

~3MB
~62K SLoC