New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add short example of using jc with NGS? #245
Comments
Hi Ilya - yes, I think this would be fine. I would, however, like to link it to a discussion (maybe on the jc discussion area or somewhere else) where there are multiple examples of using jc with next-gen shells. That way we could feature the NGS example in the readme and provide more detail somewhere else. |
Sounds good. As to implementation, I think GitHub Wiki page would be great. Let's say "Using jc from Different Shells" or alike. Hmm... "Wiki" tab is redirecting back to main page. Is it enabled? |
I haven't enabled the Wiki. Any benefit to using that over Discussions? |
I think it's better semantic fit. Wiki page is for information that people can edit in random places vs discussion, where typically messages appended at the bottom, like in a forum. Side note: not sure about discussions but Wiki is a git repo so one can clone it and use favorite IDE. |
GitHub Wiki examples:
Sounds like a fit. Source: https://docs.github.com/en/communities/documenting-your-project-with-wikis/about-wikis |
I think that makes sense - it just seems like it will be odd to have a Wiki with a single article. I guess I could populate with some other content from discussions/blogs as well. |
Yep, it will also grow organically with time. |
I've got a little skeleton going. Feel free to add examples here: https://github.com/kellyjonbrazil/jc/wiki/Using-jc-With-Different-Shells |
In Next Generation Shell, you will typically use the double-backtick "run and parse" syntax with `jc` and built-in features for data filtering and other manipulation. Examples:
``jc dig example.com``[0].answer
``jc ifconfig``.the_one({"name": "en0"}).ipv4_addr
``jc ifconfig``.name.filter(/tun/)
``jc ifconfig``.filter({"name": /tun/}).mtu
Notes:
* Non-zero exit code from `jc` will cause an exception to be thrown.
* The double-backtick will parse any JSON, not just output of `jc`.
* `the_one()` will throw an exception if there is not exactly one matching item.
* `.name` and `.mtu` result an array as `.FIELD_NAME` on an array is defined as mapping each element to the given field.
Next Generation Shell documentation: https://ngs-lang.org/doc/latest/index.html |
Looking good! I haven't tested the other shell examples yet - might have some time to do that tomorrow. Yeah, I think I might do a short example from all or maybe a sample of the shells with link backs and one final link for "more shells" or something. |
I just disabled Restrict editing to collaborators only. I wonder if you can edit now or if it sends me a PR or something? |
Just letting you know, it's possible to have a link to a specific heading on a wiki page. |
I got this when testing NGS (via
Might be cool to show a variable assignment example like the others. I've tested all of the other examples except for the cmd.exe. I'll spin up a Windows VM for that and test next. |
This seems to work fine, though:
|
I've seen the Wiki. You did all the work :) Looks good! The double-backtick syntax is not accepted at top-level and the example was showing just that. |
I have added a section to the README.md in the |
I went ahead and turned this into a blog post, too: https://blog.kellybrazil.com/2022/05/19/working-with-json-in-various-shells/ |
"WIKI article" should be "wiki page", I think "page" is much more commonly used in the context of "wiki". https://en.wikipedia.org/wiki/Wiki
Maybe something like: This allows running
Nice! Watch out though because it might go out of sync with the wiki page (after it's edited). |
I guess it's done and we can close the issue? |
Sounds good - I'll pull this into |
I would like to add a short example of using jc with NGS (to the main readme). That would be related and just after the Python example. Something like this (plus some explanation):
Would this be OK?
The text was updated successfully, but these errors were encountered: