PICNIC Is Config Notation Interpreter/Converter

Related tags

Miscellaneous picnic
Overview

picnic

PICNIC Is Config Notation Interpreter/Converter 🦀

github

PICNIC

PICNIC's name is powered by AI, which immediately makes it worth your time:

Human: Please come up with a recursive name for my cli project which interprets configuration files and prints environment variables.

ChatGPT: That sounds like a useful tool! How about naming it PICNIC, which stands for "PICNIC Is Config Notation Interpreter/Converter". This fits the recursive acronym style you're looking for, and it also gives a sense of ease and simplicity, as if dealing with various config file formats is just a "picnic" with this tool.

Features

Extract data from json and .env files (soon yaml, toml, csv, xml)
Match keys with the same syntax as your file format
Output matched results, or everything. Source it with eval
Optionally spawn tiny binaries that print your values (useful when outside shell scripting, e.g. Nix)

Installation

From crates.io

cargo install picnic-rs (I'm trying to get ownership for picnic)

Usage

Some json examples. The usage is similar for other formats. picnic --help for more info.

// some.json
{
  "foo": "bar",
  "baz": {
    "quz": "qork"
  },
  "boo": [
    "bah",
    {
      "lol": "lurg"
    }
  ]
}

$ picnic some.json

Output:

baz.quz=qork; export baz.quz;
boo.0=bah; export boo.0;
boo.1.lol=lurg; export boo.1.lol;
foo=bar; export foo;

Eval the output to set the environment variables:

eval $(picnic some.json)

Matching templates

Replace the values you want to extract with $ variables:

$ picnic some.json --match '{"boo": [$BAH, "lol": $LURG] }'

Output:

BAH=bah; export BAH;
LURG=lurg; export LURG;

Similarly, eval the output to set the env variables.

📝 Custom separators and casing options

$ picnic some.json --separator _ --casing upper

Output:

BAZ_QUZ=qork; export BAZ_QUZ;
BOO_0=bah; export BOO_0;
BOO_1_LOL=lurg; export BOO_1_LOL;
FOO=bar; export FOO;

💾 Spawn binaries

$ picnic some.json --spawn /tmp

Generates:

$ ls /tmp
foo
baz.quz
boo.0
boo.1.lol

Outputs:

$ ./foo
bar

$ ./baz.quz
qork

$ ./boo.0
bah

$ ./boo.1.lol
lurg

↩︎ Pipe stdin to picnic

curl -o some.json http://config.com/some_json_i_know_not_to_be_malicious.json 
eval $(cat some.json | picnic)

Contributing

Contributions are welcome! Feel free to open an issue or submit a PR.

License

APACHE-2.0 and MIT

Disclaimer

Do not eval output or generate binaries from unknown files!

You might also like...
Regorus - Rego interpreter, analyzer and validator written in Rust

regorus THIS REPOSITORY IS IN ACTIVE DEVELOPMENT AND NOT INTENDED FOR PRODUCTION USE. Regorus is a Rego interpreter, analyzer and checker written in R

Compiler & Interpreter for the (rather new and very experimental) Y programming language.

Y Lang Why would anyone build a new (and rather experimental) language with no real world use case. Design Y (pronounced as why) is based on the idea

An expression based data notation, aimed at transpiling itself to any cascaded data notation.

Lala An expression oriented data notation, aimed at transpiling itself to any cascaded data notation. Lala is separated into three components: Nana, L

`haproxy_autconfd` is a daemon that automatically assembles a HAProxy config and restarts HAProxy if the config changes

haproxy_autconfd Welcome to haproxy_autconfd 🎉 haproxy_autconfd is a daemon that automatically assembles a HAProxy config and restarts HAProxy if the

Rusty Object Notation

Rusty Object Notation RON is a simple readable data serialization format that looks similar to Rust syntax. It's designed to support all of Serde's da

Rust experiments involving Haskell-esque do notation, state, failure and Nom parsers!

Introduction As a long time Haskell developer recently delving into Rust, something I've really missed is monads and do notation. One thing monadic do

a cheat-sheet for mathematical notation in Rust 🦀 code form

math-as-rust 🦀 Based on math-as-code This is a reference to ease developers into mathematical notation by showing comparisons with Rust code.

Easily create dynamic css using json notation

jss! This crate provides an easy way to write dynamic css using json notation. This gives you more convenient than you think. Considering using a dyna

Eon-rs - A reference parser for EON (Extensible Object Notation)

eon-rs eon-rs is a Rust library for parsing EON. Installation Add eon-rs = "1.0.0" to your Cargo.toml file. Usage use eon_rs; // Read EON from file l

A library for transcoding between bytes in Astro Notation Format and Native Rust data types.

Rust Astro Notation A library for transcoding between hexadecimal strings in Astro Notation Format and Native Rust data types. Usage In your Cargo.tom

Object Notation Programming Language?
Object Notation Programming Language?

You may have questions ONLang - Object Notation Language (jsON) VSCode extension - OnLang 1. God, what the f**** is this ONLang is an experimental, es

Friendly symbol notation.

symmie Friendly symbol notation. The goal of this project is to provide a systematic notation for technical symbols and emoji. The notation consist of

Artsy pixel image to vector graphics converter
Artsy pixel image to vector graphics converter

inkdrop inkdrop is an artsy bitmap to vector converter. Command line interface The CLI binary is called inkdrop-cli and reads almost any image bitmap

A Simple Image to Ascii converter in Rust
A Simple Image to Ascii converter in Rust

Image to Ascii A Simple Image to Ascii converter in Rust Brief 📖 In my way to learn Rust i decided to make this converter. Challenges 🐢 new to Rust

Converter valores entre moedas com RUST.
Converter valores entre moedas com RUST.

Exchange Rust 🦀 Uma CLI escrita em Rust que converte um valor de uma moeda para outra consumindo a API CurrencyConverterApi (projeto de estudo). Util

Camera RAW to DNG file format converter

DNGLab - A camera RAW to DNG file format converter Command line tool to convert camera RAW files to Digital Negative Format (DNG). It is currently in

A fast wordlist to nthash converter

nthasher A fast wordlist to nthash converter Usage Pass it a UTF8 encoded wordlist, and write the output to a file. ./nthasher wordlist wordlist.n

elite - c converter

elite - c converter

elite - python3 converter

elite - python3 converter

Owner
Fabricio Demattê
welcome to my profile... i hope you don't mind the rust
Fabricio Demattê
This crate defines a single macro that is a brainfunct compile-time interpreter.

Compile Protection This crate defines a single macro that is a brainfunct compile-time interpreter. One example is as follows #![recursion_limit = "18

John Marsden 7 Nov 29, 2021
Brainfuck interpreter written in rust

Brainfuck Interpreter Written in Rust Simple Interpreter that runs bare Brainfuck and extends it with debug command # which prints content of first te

Was 1 Nov 28, 2021
The brainfuck language interpreter written in Rust

The brainfuck language interpreter written in Rust

Jan Štaffa 1 Feb 21, 2022
rlox-interpreter is an AST-walking implementation of Bob Nystrom's Lox language in Rust.

rlox-interpreter rlox-interpreter is an AST-walking implementation of Bob Nystrom's Lox language in Rust. Disclaimer: This is my first Rust project, d

Paul Fedorow 3 Oct 5, 2022
A Brainf** interpreter written in rust 🦀

Brainf Interpreter An interpreter for the esoteric programming language Brainfuck written in rust ?? Compilation NOTE: To compile the project, you nee

Chitram Dasgupta 2 Sep 12, 2022
Risc-V assembly interpreter built with pure Rust

Risc-V Interpreter Interpreter for Risc-V assembly built with Rust Report bug · Request feature Table of contents Quick start Exemple Program Instruct

null 2 Aug 24, 2022
Brainf - A brainfuck interpreter written in Rust 🦀

brainf A brainfuck interpreter written in Rust ?? . Do not I wrote this in my spare time... but still its good! Run Locally Clone the project git cl

Nav 3 Oct 8, 2022
Brainfu*k interpreter and REPL written in Rust🦀

brainfuck interpreter: a simple brainfuck interpreter and REPL writen in rust ?? Read this in other languages. AR Arabic-العربية Features Run brainfuc

Anas Elgarhy 7 Feb 1, 2023
A fast, powerful and configurable interpreter written in Rust

brainfuck-interpreter Overview A fast, powerful and configurable interpreter written in Rust, which allows various options to meet different demends,

Justin Chen 4 Feb 12, 2023
A simple interpreter written in Rust programming language.

Interpreter in Rust A simple interpreter written in Rust programming language. Getting Started These instructions will get you a copy of the project u

Ismail Mosleh 5 Feb 17, 2023