Coding Challenge #45 - yq
John Crickett
Helping you become a better software engineer by building real-world applications.
This challenge is to build your own version of yq
The tool?yq?is a lightweight and flexible command-line YAML processor. It’s useful for processing YAML allowing us to quickly and effectively filter out the bits we want.
If You Enjoy Coding Challenges Here Are Five Ways You Can Help Support It
Coding Challenges News
I’m currently asking for feedback on what challenges to cover next. I’d appreciate your thoughts on?in this post. Thanks.
Purchasing Price Parity - I’m now offering PPP on my courses making them more accessible for everyone. Many thanks to all those who suggested it.
The Challenge - Building Your Own yq
The command line tool?yq?is like?jq?for YAML data - you can use it to and filter and transform YAML data, much like you would JSON dats with?jq. By the way, a past?Coding Challenge?was to?build your own jq if you fancy giving that a go.
Step Zero
Like?yq?itself we’re zero-indexed! In this step you’re going to set your environment up ready to begin developing our?yq?clone:?ccyq.
You can download some test YAML from my dropbox here.
领英推荐
Step 1
In this step your goal is to open the yaml file, read it and print it. You could parse it at this point or just read it and print it line by line.
The outcome should look something like this:
% ccyq quotes.yaml
quotes:
- id: 1
quote: It is bad for a young man to sin; but it is worse for an old man to sin.
author: Abu Bakr (R.A)
<snip>
- id: 5
quote: >-
These Capitalists Generally Act Harmoniously And In Concert, To Fleece The People.
author: Abraham Lincoln
N.B. I’ve trimmed the output to just show the first and last quote.
Continued...
You can find Step 2 and beyond on the Coding Challenges website as build your own yq.
Or if you'd rather get the whole challenge delivered to you inbox every week, you can subscribe on the Coding Challenges Substack.
2 Other Ways I Can Help You:
LedgerSummit.com
1 年Incredible lineup of challenges! ?? Each one is a unique opportunity to dive deep into coding fundamentals and beyond. Whether it's crafting your own yq or building a Redis server, there's something for every skill level. Hats off to you for fostering such an engaging learning community! Subscribing for sure to not miss out on the next challenge. Keep them coming!
Software Engineer | Python Enthusiast | AI Nerd | Good Person to Know
1 年Super unique idea! I love what you’re building.
Senior Software Engineer
1 年These challenges helped me get my Go knowledge from 0 to where I'm confident with the syntax and can build small CLI applications without much effort. ?? recommended.