Skip to content

Commit 7cf3d1e

Browse files
author
Bryan Cross
committed
Re-adding check for zero args
1 parent ed3af14 commit 7cf3d1e

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

graphql/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ This repository holds query samples for the GitHub GraphQL API. It's an easy way
99
1. Pick the name of one of the included queries in the `/queries` directory, such as `viewer.graphql`.
1010
1. Run `./index.js <query_file> <token>`
1111

12-
To change variables values, just modify the variables in the `.graphql` file.
12+
To change variable values, modify the variables in the `.graphql` file.

graphql/index.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,29 @@ program
1414
console.log("Running query: " + file);
1515
runQuery(file, token);
1616
})
17-
.description('Execute specified GraphQL query');
17+
.description('Execute specified GraphQL query.');
1818

19-
program.parse(process.argv);
19+
program.on('--help', function(){
20+
console.log('');
21+
console.log(' Arguments:');
22+
console.log('');
23+
console.log(' file : Path to file containing GraphQL');
24+
console.log(' token: Properly scoped GitHub PAT');
25+
console.log('');
26+
});
2027

21-
if (!process.argv.slice(2).length)
28+
//Commander doesn't seem to do anything when both required arguments are missing
29+
//So we'll check the old-fashioned way
30+
if(process.argv.length != 4)
2231
{
23-
console.log("Missing query file and/or token argument");
24-
process.exitCode = 1;
32+
console.log('Usage: ./index.js ' + program.usage());
33+
process.exitCode = 1
2534
}
2635

36+
program.parse(process.argv);
37+
2738
function runQuery(file, token) {
28-
39+
2940
try {
3041
var queryText = fs.readFileSync(file, "utf8");
3142
}

graphql/queries/7-org-with-variables.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ query getOrg($orgLogin:String!) {
22
organization(login: $orgLogin) {
33
login
44
name
5-
members(first: 1) {
5+
members(first: 100) {
66
edges {
77
node {
88
login

0 commit comments

Comments
 (0)