Skip to content

Commit 27905e7

Browse files
committed
restructured repo
1 parent 448839d commit 27905e7

File tree

5 files changed

+92
-3
lines changed

5 files changed

+92
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/docs/.cache
55
/docs/venv
66
/docs/site
7+
/docs/docs
8+
19.9 KB
Loading

docs/index.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,7 @@
406406

407407

408408
<h1 id="welcome-to-rjq">Welcome to rjq</h1>
409-
<!-- For full documentation visit [mkdocs.org](https://www.mkdocs.org). -->
410-
409+
<p><code>rjq</code> is a simple and lightweight CLI JSON filtering tool designed for Windows and Linux.</p>
411410
<h2 id="flags">Flags</h2>
412411
<ul>
413412
<li><code>--load</code> - Loads JSON data from file.</li>

docs/index.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Welcome to rjq
2+
3+
`rjq` is a simple and lightweight CLI JSON filtering tool designed for Windows and Linux.
4+
5+
## Flags
6+
7+
- `--load` - Loads JSON data from file.
8+
- `--query` - Query to be performed on the dataset.
9+
- `--params` - Selects specific fields that will be returned as result.
10+
11+
## Commands
12+
13+
* `rjq --load="<file name>"` - Loads JSON data from file and returns all the data as result.
14+
* `rjq --query="<query string>"` - Sets query string.
15+
* `rjq --params="<comma separated field names>"` - Sets fileds for the result
16+
17+
## Usage
18+
19+
* `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.
20+
* `stto --json cpython | rjq --query="<query string>" --params="<comma separated field names>"` - Piping output from other program.
21+
22+
***N.B.** [stto](https://github.com/mainak55512/stto) is a line of code counter used as an example here.*
23+
24+
## Query structure
25+
26+
Query is set by `--query` flag, e.g. `--query="age > 30 && percentage >= 50.0"`.
27+
rjq has a simple query structure, it follows `[field_name] [operator] [Value]` pattern.
28+
29+
- `field_name` - It is the field name from the supplied dataset. For nested objects '.' operator should be used for accessing values, e.g.
30+
to access 'town' value from the following json:
31+
32+
```
33+
{
34+
"_id": "88L33FM4VQBB1QYH",
35+
"address": {
36+
"postode": "CR45 9NE",
37+
"street": "3137 Stich Avenue",
38+
"town": "Swanley"
39+
}
40+
}
41+
```
42+
43+
use `address.town` in the field_name of the query.
44+
45+
***N.B.** `field_name` should not be wrapped in any quotes.*
46+
47+
- `Operator` - The following operators are supported for now:
48+
* `=` - `equal_to` operator, checks if both sides are same.
49+
* `!=` - `not_equals` operator, checks if both sides are NOT same.
50+
* `>` - `greather_than` operator, checks if `left` is greater than to `right`.
51+
* `<` - `less_than` operator, checks if `left` is lesser than to `right`.
52+
* `>=` - `greather_than_or_equal` operator, checks if `left` is greater than to `right` or same.
53+
* `<=` - `less_than_or_equal` operator, checks if `left` is lesser than to `right` or same.
54+
* `&&` - `and` operator, joins two Binary expressions, e.g. `age > 18 && percentage < 34.0`.
55+
* `||` - `or` operator, joins two Binary expressions, e.g. `age > 18 || percentage < 34.0`.
56+
- `Value` - rjq supports 3 types of values, `string`, `boolean` & `number`.
57+
* `String` - strings should be wrapped in single quotes (') only, e.g. `'name'`, `'address'` etc.
58+
* `Boolean` - `true`/`false` without any quotes.
59+
* `Number` - Any number without quotes. For comparing decimal numbers decimal point should be provided, e.g. for quering `age` & `percentage` of the following -
60+
```
61+
{
62+
"age": 30,
63+
...
64+
"percentage": 56.34,
65+
...
66+
}
67+
```
68+
use something like `age > 18 && percentage > 50.0`.
69+
70+
## Parameters
71+
72+
Output parameters are set by `--params` flag e.g. `--params="name, address.town"`.
73+
Dot walking is supported for nested object fields.
74+
75+
## Project layout
76+
77+
src/
78+
main.rs # Entry point for the program.
79+
lexer.rs # Lexer of the program, tokenizes the query string.
80+
parser.rs # Parser of the program, creates Abstract syntax tree from the tokens generated by the lexer.
81+
interpreter.rs # Interprets the AST and returns boolean value after evaluating the query.
82+
helper.rs # Utility file.
83+
84+
Cargo.toml # Configuration file for the project.
85+
86+
LICENSE # License file.
87+
88+
README.md # Readme file.

docs/search/search_index.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +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>"}]}
1+
{"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 commit comments

Comments
 (0)