Skip to content

Yord/shargs-example-sync-sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shargs-example-sync-sql is a sample application of shargs 🦈.

See the shargs github repository for more details!

node version license PRs Welcome

Setup

$ git clone https://github.com/Yord/shargs-example-sync-sql.git
$ cd shargs-example-sync-sql
$ npm i
$ chmod +x ./sql

Example

This repository is a simple example of a command-line parser build with shargs. The program can be found in the sql script.

Run the Example

The sql script parses a very simple version of the SQL query language:

./sql \
SELECT 'alias, power' \
FROM superheroes,powers \
WHERE 'id = superhero_id AND universe = "Marvel"' \
GROUP BY alias \
HAVING 'COUNT(power) > 5' \
ORDER BY alias \
LIMIT 10

This prints the following:

{
  _: [],
  select: [ 'alias', 'power' ],
  from: [ 'superheroes', 'powers' ],
  where: 'id = superhero_id AND universe = "Marvel"',
  groupBy: 'alias',
  having: 'COUNT(power) > 5',
  orderBy: 'alias',
  limit: 10
}

Note that the order of the object fields may be different depending on the node version.

Reporting Issues

Please report issues in the shargs tracker!

License

shargs-example-sync-sql is MIT licensed.

About

shargs-example-sync-sql is a sample application of shargs 🦈.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks