Skip to content

Commit

Permalink
Merge pull request #29 from jrjohnson/add-lookup
Browse files Browse the repository at this point in the history
Add lookup command
  • Loading branch information
dartajax authored Feb 8, 2019
2 parents d7f9b52 + 927abaf commit accf9d8
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions bin/lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env node
'use strict';

const findIliosUser = require('../lib/findIliosUser');
const createJWT = require('../lib/createJWT');
const fetch = require('node-fetch');
const aws = require('aws-sdk');

const meow = require('meow');

const cli = meow(`
Usage
$ lookup <ltiUserId> <apiServer> <apiNameSpace> <iliosSecret> <searchString>
Examples
$ lookup 61 'https://demo-api.com' 'api/v1' 'secret' test@example.edu
`);
const lookup = ([ltiUserId, apiServer, apiNameSpace, iliosSecret, searchString]) => {
if (
undefined == ltiUserId ||
undefined == apiServer ||
undefined == apiNameSpace ||
undefined == iliosSecret ||
undefined == searchString) {
process.stderr.write('Missing parameters <ltiUserId> <apiServer> <apiNameSpace> <iliosSecret> <searchString> are required.\n');
cli.showHelp([1]);
}
const iliosMatchField = 'authentication-username'; //we only support one right now
const config = { ltiUserId, apiServer, apiNameSpace, iliosSecret, iliosMatchField };
findIliosUser({
fetch,
createJWT,
config,
searchString,
aws
}).then(userId => {
process.stdout.write(`User ID: ${userId}\n`);
});
};

lookup(cli.input);

0 comments on commit accf9d8

Please sign in to comment.