jiq
v0.0.10
Published
Use existing javascript knowledge to query or modify data
Downloads
26
Maintainers
Readme
Introduction
Javascript Inline Query (jiq) a command line tool.
Use existing javascript knowledge to query or modify almost any type data, files and directory.
Installation
npm -g install jiq
or
yarn global add jiq
Usage
jiq <file/path/url> <your javascript where $ holds data>
Let's start
jiq
output
┌──────────────┬───────────┬──────┐
│ base │ type │ size │
├──────────────┼───────────┼──────┤
│ .git │ directory │ -- │
│ .vscode │ directory │ -- │
│ assets │ directory │ -- │
│ build │ directory │ -- │
│ docs │ directory │ -- │
│ node_modules │ directory │ -- │
│ src │ directory │ -- │
│ stubs │ directory │ -- │
└──────────────┴───────────┴──────┘
filter directory only
jiq . '.filter(x => x.isDirectory)'
output
┌──────────────┬───────────┬──────┐
│ base │ type │ size │
├──────────────┼───────────┼──────┤
│ .git │ directory │ -- │
│ .vscode │ directory │ -- │
│ assets │ directory │ -- │
│ build │ directory │ -- │
│ docs │ directory │ -- │
│ node_modules │ directory │ -- │
│ src │ directory │ -- │
│ stubs │ directory │ -- │
└──────────────┴───────────┴──────┘
rename js to ts file
jiq . '.filter(x => x.ext === "js").each(x => x.rename(x.name + ".ts"))'
output
rename all js files to ts on specified directory
goto File section
let say we have a package.json
file
jiq package.json .scripts
{
"start": "node index.js"
}
see JSON
get json from url and print as table.
jiq https://reqres.in/api/users '.data' --print table
output
┌─────────┬────┬────────────────────────────┬────────────┬───────────┬───────────────────────────────────────────────────────────────────────┐
│ (index) │ id │ email │ first_name │ last_name │ avatar │
├─────────┼────┼────────────────────────────┼────────────┼───────────┼───────────────────────────────────────────────────────────────────────┤
│ 0 │ 1 │ '[email protected]' │ 'George' │ 'Bluth' │ 'https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg' │
│ 1 │ 2 │ '[email protected]' │ 'Janet' │ 'Weaver' │ 'https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jpg' │
│ 2 │ 3 │ '[email protected]' │ 'Emma' │ 'Wong' │ 'https://s3.amazonaws.com/uifaces/faces/twitter/olegpogodaev/128.jpg' │
│ 3 │ 4 │ '[email protected]' │ 'Eve' │ 'Holt' │ 'https://s3.amazonaws.com/uifaces/faces/twitter/marcoramires/128.jpg' │
│ 4 │ 5 │ '[email protected]' │ 'Charles' │ 'Morris' │ 'https://s3.amazonaws.com/uifaces/faces/twitter/stephenmoon/128.jpg' │
│ 5 │ 6 │ '[email protected]' │ 'Tracey' │ 'Ramos' │ 'https://s3.amazonaws.com/uifaces/faces/twitter/bigmancho/128.jpg' │
└─────────┴────┴────────────────────────────┴────────────┴───────────┴───────────────────────────────────────────────────────────────────────┘
see printer
with json output
jiq https://reqres.in/api/users '.data.head(3).pick({email: "email", name: (x) => x.first_name + " " + x.last_name })'
see all available array functions array, and JSON
output
[
{ email: '[email protected]', name: 'George Bluth' },
{ email: '[email protected]', name: 'Janet Weaver' },
{ email: '[email protected]', name: 'Emma Wong' }
]
Read full documentation here.