Skip to content

Commit

Permalink
restructured repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mainak55512 committed Oct 13, 2024
1 parent 448839d commit 27905e7
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/docs/.cache
/docs/venv
/docs/site
/docs/docs

Binary file added docs/assets/images/social/docs/index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,7 @@


<h1 id="welcome-to-rjq">Welcome to rjq</h1>
<!-- For full documentation visit [mkdocs.org](https://www.mkdocs.org). -->

<p><code>rjq</code> is a simple and lightweight CLI JSON filtering tool designed for Windows and Linux.</p>
<h2 id="flags">Flags</h2>
<ul>
<li><code>--load</code> - Loads JSON data from file.</li>
Expand Down
88 changes: 88 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Welcome to rjq

`rjq` is a simple and lightweight CLI JSON filtering tool designed for Windows and Linux.

## Flags

- `--load` - Loads JSON data from file.
- `--query` - Query to be performed on the dataset.
- `--params` - Selects specific fields that will be returned as result.

## Commands

* `rjq --load="<file name>"` - Loads JSON data from file and returns all the data as result.
* `rjq --query="<query string>"` - Sets query string.
* `rjq --params="<comma separated field names>"` - Sets fileds for the result

## Usage

* `rjq --load="test.json" --query="<query string>" --params="<comma separated field names>"` - Loads data from file, applies the query, returns array of objects with fields specified by '--params' flag.
* `stto --json cpython | rjq --query="<query string>" --params="<comma separated field names>"` - Piping output from other program.

***N.B.** [stto](https://github.com/mainak55512/stto) is a line of code counter used as an example here.*

## Query structure

Query is set by `--query` flag, e.g. `--query="age > 30 && percentage >= 50.0"`.
rjq has a simple query structure, it follows `[field_name] [operator] [Value]` pattern.

- `field_name` - It is the field name from the supplied dataset. For nested objects '.' operator should be used for accessing values, e.g.
to access 'town' value from the following json:

```
{
"_id": "88L33FM4VQBB1QYH",
"address": {
"postode": "CR45 9NE",
"street": "3137 Stich Avenue",
"town": "Swanley"
}
}
```
use `address.town` in the field_name of the query.
***N.B.** `field_name` should not be wrapped in any quotes.*
- `Operator` - The following operators are supported for now:
* `=` - `equal_to` operator, checks if both sides are same.
* `!=` - `not_equals` operator, checks if both sides are NOT same.
* `>` - `greather_than` operator, checks if `left` is greater than to `right`.
* `<` - `less_than` operator, checks if `left` is lesser than to `right`.
* `>=` - `greather_than_or_equal` operator, checks if `left` is greater than to `right` or same.
* `<=` - `less_than_or_equal` operator, checks if `left` is lesser than to `right` or same.
* `&&` - `and` operator, joins two Binary expressions, e.g. `age > 18 && percentage < 34.0`.
* `||` - `or` operator, joins two Binary expressions, e.g. `age > 18 || percentage < 34.0`.
- `Value` - rjq supports 3 types of values, `string`, `boolean` & `number`.
* `String` - strings should be wrapped in single quotes (') only, e.g. `'name'`, `'address'` etc.
* `Boolean` - `true`/`false` without any quotes.
* `Number` - Any number without quotes. For comparing decimal numbers decimal point should be provided, e.g. for quering `age` & `percentage` of the following -
```
{
"age": 30,
...
"percentage": 56.34,
...
}
```
use something like `age > 18 && percentage > 50.0`.
## Parameters
Output parameters are set by `--params` flag e.g. `--params="name, address.town"`.
Dot walking is supported for nested object fields.
## Project layout
src/
main.rs # Entry point for the program.
lexer.rs # Lexer of the program, tokenizes the query string.
parser.rs # Parser of the program, creates Abstract syntax tree from the tokens generated by the lexer.
interpreter.rs # Interprets the AST and returns boolean value after evaluating the query.
helper.rs # Utility file.
Cargo.toml # Configuration file for the project.
LICENSE # License file.
README.md # Readme file.
2 changes: 1 addition & 1 deletion docs/search/search_index.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to rjq","text":""},{"location":"#flags","title":"Flags","text":"<ul> <li><code>--load</code> - Loads JSON data from file.</li> <li><code>--query</code> - Query to be performed on the dataset.</li> <li><code>--params</code> - Selects specific fields that will be returned as result.</li> </ul>"},{"location":"#commands","title":"Commands","text":"<ul> <li><code>rjq --load=\"&lt;file name&gt;\"</code> - Loads JSON data from file and returns all the data as result.</li> <li><code>rjq --query=\"&lt;query string&gt;\"</code> - Sets query string.</li> <li><code>rjq --params=\"&lt;comma separated field names&gt;\"</code> - Sets fileds for the result</li> </ul>"},{"location":"#usage","title":"Usage","text":"<ul> <li><code>rjq --load=\"test.json\" --query=\"&lt;query string&gt;\" --params=\"&lt;comma separated field names&gt;\"</code> - Loads data from file, applies the query, returns array of objects with fields specified by '--params' flag.</li> <li> <p><code>stto --json cpython | rjq --query=\"&lt;query string&gt;\" --params=\"&lt;comma separated field names&gt;\"</code> - Piping output from other program.</p> <p>N.B. stto is a line of code counter used as an example here.</p> </li> </ul>"},{"location":"#query-structure","title":"Query structure","text":"<p>Query is set by <code>--query</code> flag, e.g. <code>--query=\"age &gt; 30 &amp;&amp; percentage &gt;= 50.0\"</code>. rjq has a simple query structure, it follows <code>[field_name] [operator] [Value]</code> pattern.</p> <ul> <li> <p><code>field_name</code> - It is the field name from the supplied dataset. For nested objects '.' operator should be used for accessing values, e.g. to access 'town' value from the following json:</p> <p><code>{ \"_id\": \"88L33FM4VQBB1QYH\", \"address\": { \"postode\": \"CR45 9NE\", \"street\": \"3137 Stich Avenue\", \"town\": \"Swanley\" } }</code></p> <p>use <code>address.town</code> in the field_name of the query.</p> <p>N.B. <code>field_name</code> should not be wrapped in any quotes.</p> </li> <li> <p><code>Operator</code> - The following operators are supported for now:</p> <ul> <li><code>=</code> - <code>equal_to</code> operator, checks if both sides are same.</li> <li><code>!=</code> - <code>not_equals</code> operator, checks if both sides are NOT same.</li> <li><code>&gt;</code> - <code>greather_than</code> operator, checks if <code>left</code> is greater than to <code>right</code>.</li> <li><code>&lt;</code> - <code>less_than</code> operator, checks if <code>left</code> is lesser than to <code>right</code>.</li> <li><code>&gt;=</code> - <code>greather_than_or_equal</code> operator, checks if <code>left</code> is greater than to <code>right</code> or same.</li> <li><code>&lt;=</code> - <code>less_than_or_equal</code> operator, checks if <code>left</code> is lesser than to <code>right</code> or same.</li> <li><code>&amp;&amp;</code> - <code>and</code> operator, joins two Binary expressions, e.g. <code>age &gt; 18 &amp;&amp; percentage &lt; 34.0</code>.</li> <li><code>||</code> - <code>or</code> operator, joins two Binary expressions, e.g. <code>age &gt; 18 || percentage &lt; 34.0</code>.</li> </ul> </li> <li><code>Value</code> - rjq supports 3 types of values, <code>string</code>, <code>boolean</code> &amp; <code>number</code>.<ul> <li><code>String</code> - strings should be wrapped in single quotes (') only, e.g. <code>'name'</code>, <code>'address'</code> etc.</li> <li><code>Boolean</code> - <code>true</code>/<code>false</code> without any quotes.</li> <li><code>Number</code> - Any number without quotes. For comparing decimal numbers decimal point should be provided, e.g. for quering <code>age</code> &amp; <code>percentage</code> of the following - <code>{ \"age\": 30, ... \"percentage\": 56.34, ... }</code> use something like <code>age &gt; 18 &amp;&amp; percentage &gt; 50.0</code>.</li> </ul> </li> </ul>"},{"location":"#parameters","title":"Parameters","text":"<p>Output parameters are set by <code>--params</code> flag e.g. <code>--params=\"name, address.town\"</code>. Dot walking is supported for nested object fields.</p>"},{"location":"#project-layout","title":"Project layout","text":"<pre><code>src/\n main.rs # Entry point for the program.\n lexer.rs # Lexer of the program, tokenizes the query string.\n parser.rs # Parser of the program, creates Abstract syntax tree from the tokens generated by the lexer.\n interpreter.rs # Interprets the AST and returns boolean value after evaluating the query.\n helper.rs # Utility file.\n\nCargo.toml # Configuration file for the project.\n\nLICENSE # License file.\n\nREADME.md # Readme file.\n</code></pre>"}]}
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to rjq","text":"<p><code>rjq</code> is a simple and lightweight CLI JSON filtering tool designed for Windows and Linux.</p>"},{"location":"#flags","title":"Flags","text":"<ul> <li><code>--load</code> - Loads JSON data from file.</li> <li><code>--query</code> - Query to be performed on the dataset.</li> <li><code>--params</code> - Selects specific fields that will be returned as result.</li> </ul>"},{"location":"#commands","title":"Commands","text":"<ul> <li><code>rjq --load=\"&lt;file name&gt;\"</code> - Loads JSON data from file and returns all the data as result.</li> <li><code>rjq --query=\"&lt;query string&gt;\"</code> - Sets query string.</li> <li><code>rjq --params=\"&lt;comma separated field names&gt;\"</code> - Sets fileds for the result</li> </ul>"},{"location":"#usage","title":"Usage","text":"<ul> <li><code>rjq --load=\"test.json\" --query=\"&lt;query string&gt;\" --params=\"&lt;comma separated field names&gt;\"</code> - Loads data from file, applies the query, returns array of objects with fields specified by '--params' flag.</li> <li> <p><code>stto --json cpython | rjq --query=\"&lt;query string&gt;\" --params=\"&lt;comma separated field names&gt;\"</code> - Piping output from other program.</p> <p>N.B. stto is a line of code counter used as an example here.</p> </li> </ul>"},{"location":"#query-structure","title":"Query structure","text":"<p>Query is set by <code>--query</code> flag, e.g. <code>--query=\"age &gt; 30 &amp;&amp; percentage &gt;= 50.0\"</code>. rjq has a simple query structure, it follows <code>[field_name] [operator] [Value]</code> pattern.</p> <ul> <li> <p><code>field_name</code> - It is the field name from the supplied dataset. For nested objects '.' operator should be used for accessing values, e.g. to access 'town' value from the following json:</p> <p><code>{ \"_id\": \"88L33FM4VQBB1QYH\", \"address\": { \"postode\": \"CR45 9NE\", \"street\": \"3137 Stich Avenue\", \"town\": \"Swanley\" } }</code></p> <p>use <code>address.town</code> in the field_name of the query.</p> <p>N.B. <code>field_name</code> should not be wrapped in any quotes.</p> </li> <li> <p><code>Operator</code> - The following operators are supported for now:</p> <ul> <li><code>=</code> - <code>equal_to</code> operator, checks if both sides are same.</li> <li><code>!=</code> - <code>not_equals</code> operator, checks if both sides are NOT same.</li> <li><code>&gt;</code> - <code>greather_than</code> operator, checks if <code>left</code> is greater than to <code>right</code>.</li> <li><code>&lt;</code> - <code>less_than</code> operator, checks if <code>left</code> is lesser than to <code>right</code>.</li> <li><code>&gt;=</code> - <code>greather_than_or_equal</code> operator, checks if <code>left</code> is greater than to <code>right</code> or same.</li> <li><code>&lt;=</code> - <code>less_than_or_equal</code> operator, checks if <code>left</code> is lesser than to <code>right</code> or same.</li> <li><code>&amp;&amp;</code> - <code>and</code> operator, joins two Binary expressions, e.g. <code>age &gt; 18 &amp;&amp; percentage &lt; 34.0</code>.</li> <li><code>||</code> - <code>or</code> operator, joins two Binary expressions, e.g. <code>age &gt; 18 || percentage &lt; 34.0</code>.</li> </ul> </li> <li><code>Value</code> - rjq supports 3 types of values, <code>string</code>, <code>boolean</code> &amp; <code>number</code>.<ul> <li><code>String</code> - strings should be wrapped in single quotes (') only, e.g. <code>'name'</code>, <code>'address'</code> etc.</li> <li><code>Boolean</code> - <code>true</code>/<code>false</code> without any quotes.</li> <li><code>Number</code> - Any number without quotes. For comparing decimal numbers decimal point should be provided, e.g. for quering <code>age</code> &amp; <code>percentage</code> of the following - <code>{ \"age\": 30, ... \"percentage\": 56.34, ... }</code> use something like <code>age &gt; 18 &amp;&amp; percentage &gt; 50.0</code>.</li> </ul> </li> </ul>"},{"location":"#parameters","title":"Parameters","text":"<p>Output parameters are set by <code>--params</code> flag e.g. <code>--params=\"name, address.town\"</code>. Dot walking is supported for nested object fields.</p>"},{"location":"#project-layout","title":"Project layout","text":"<pre><code>src/\n main.rs # Entry point for the program.\n lexer.rs # Lexer of the program, tokenizes the query string.\n parser.rs # Parser of the program, creates Abstract syntax tree from the tokens generated by the lexer.\n interpreter.rs # Interprets the AST and returns boolean value after evaluating the query.\n helper.rs # Utility file.\n\nCargo.toml # Configuration file for the project.\n\nLICENSE # License file.\n\nREADME.md # Readme file.\n</code></pre>"}]}

0 comments on commit 27905e7

Please sign in to comment.