Skip to content

Commit

Permalink
feat(#10): --json
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed May 22, 2024
1 parent 3c391d9 commit e794eeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ choose from `craeted`, `updated` and `pushed`, the default one is `created`.
With `--batchsize 10` you can provide a batch-size value in the range from
10..100. The default value is `10`.

Also, with `--filename` you can provide the name of the file for the output CSV
and JSON files. The default one is `result`.
Also, with `--filename` you can provide the name of the file for the output
repos (CSV and JSON files). The default one is `result`. By default, it would
create `.csv` file only. In order to create `.json` too, just pass `--json`
option.

## How to contribute

Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const searchQuery = argv.query || '';
const startDate = argv.start || '2008-01-01';
const endDate = argv.end || now;
const dateType = argv.date || 'created';
const print = argv.json || false;

let tokens;
if (argv.tokens) {
if ('string' === typeof argv.tokens) {
Expand Down Expand Up @@ -251,8 +253,10 @@ function writeFiles(json) {
};
return data;
});
toJson(fileName, formattedResults);
toCsv(fileName, formattedResults);
if (print) {
toJson(fileName, formattedResults);
}
}

const countQuery = `query ($completeSearchQuery: String!) {
Expand Down

0 comments on commit e794eeb

Please sign in to comment.