yquery

Crates.ioyquery
lib.rsyquery
version0.1.1
sourcesrc
created_at2022-01-03 18:12:49.67749
updated_at2022-01-03 20:48:07.595485
descriptionyquery is a yaml-query command-line utility based on the idea of jquery
homepage
repositoryhttps://github.com/madsravn/yquery
max_upload_size
id507245
size19,589
Mads Ravn (madsravn)

documentation

README

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.

Copyright and License

This tool and its source is licensed under GNU GPLv3

Commit count: 27

cargo fmt