Page MenuHomeSolus

yq - cli yaml parser
Open, Needs TriagePublic

Description

Name of the software : yq
Project/product Homepage :

Why we should include this into the repository, i.e. what does it do that the alternatives do not? jq equivalent for yaml, useful to quickly parse a .yml file from bash scripts
Is it open source? Yes (Apache-2.0 / MIT)

First project is a jq wrapper written in python that supports yaml/xml/toml formats
Second project is written in golang and seems to be a little bit more popular, but it might not 100% match the jq syntax

Details

Event Timeline

JoshStrobl triaged this task as Needs More Info priority.Aug 23 2021, 3:42 PM
JoshStrobl added a subscriber: JoshStrobl.

You mention needing to parse a yml file, but what is the specific usecase? If it's regarding package.yml, we already have Golang parsing libraries so we could trivially write a tool you need that is purpose built rather than a separate utility, especially given our YAML files are not 100% aligned with the YAML specification.

My personal use case is to write quick & dirty bash functions to perform things like

gac() {
  git add *
  git commit --signoff -m"Update $(yq r package.yml 'name') to $(yq r package.yml 'version')"
}

This is very basic and I could easily do it with sed/awk/grep but I'd like also to use update the URLs in package that have multiple sources that libreoffice since currently yupdate can't deal with that, etc.

I find jq very handy to deal with REST APIs, so I thought it would be nice to have something similar for yaml too

JoshStrobl raised the priority of this task from Needs More Info to Normal.
JoshStrobl moved this task from Backlog to Accepted For Inclusion on the Package Requests board.
kyrios123 raised the priority of this task from Normal to Needs Triage.Thu, Nov 18, 9:50 AM
kyrios123 added a subscriber: DataDrake.

@JoshStrobl @DataDrake since there are 2 competiting versions of this software, do you have any preference for the source ?

FWIW I've been using the mikefarah project for a few years now and it's done everything I've wanted a yaml cli tool to do. It also seems to be the more popular of the competing tools by a significant margin according to Github stars.