From 17f53f295013aa2fd75c0e6a6ebfb8d1e3f91e7f Mon Sep 17 00:00:00 2001 From: geir Date: Wed, 25 Feb 2015 13:09:27 +0100 Subject: [PATCH] initial layout, arg parsing and main --- .gitignore | 27 +++++++++++++++++++++++++++ lib/cli.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/main.js | 15 +++++++++++++++ package.json | 20 ++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 .gitignore create mode 100644 lib/cli.js create mode 100644 lib/main.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..123ae94 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git +node_modules diff --git a/lib/cli.js b/lib/cli.js new file mode 100644 index 0000000..e70acc8 --- /dev/null +++ b/lib/cli.js @@ -0,0 +1,50 @@ +parser = require('argv-parser'); +main = require('./main'); + +var rules = { + organization: { + type: String, + required: true, + short: 'o' + }, + command: { + type: String, + required: true, + short: 'c' + }, + password: { + type: String, + required: true, + short: 's' + }, + username: { + type: String, + required: true, + short: 'u', + }, + baseurl: { + type: String, + required: true, + short: 'b', + }, + directory: { + type: String, + required: false, + short: 'd', + default: '.' + }, +}; +var data = parser.parse( process.argv, { rules: rules } ); + +data.parsed.orgUrl = data.parsed.baseurl + "/v1/o/" + data.parsed.organization; + +if ( data.parsed.command == "import" ) { + main.import( data ); +} +else if ( data.parsed.command == "execute" ) { + main.execute( data ); +} +else { + console.log( 'Unknown command: ' + data.parsed.command ); + console.log( 'Command must be one of: import|execute' ); +} diff --git a/lib/main.js b/lib/main.js new file mode 100644 index 0000000..26b4513 --- /dev/null +++ b/lib/main.js @@ -0,0 +1,15 @@ +var jf = require('jsonfile'); +var util = require('util'); + +module.exports = { + import: Import, + execute: Execute +} + +function Import( data ) { + console.log( util.inspect(data) ); +} + +function Execute( data ) { + console.log( util.inspect(data) ); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..da9e2bf --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "apigeeOrgAdmin", + "version": "0.8.0", + "description": "A CLI for Administering Apigee Edge Organizations", + "main": "lib/main.js", + "bin": { + "apigeeOrgAdmin": "lib/cli.js" + }, + "keywords": [ + "Apigee", + "CLI" + ], + "author": "Geir Sjurseth ", + "license": "MIT", + "dependencies": { + "argv-parser": "*", + "util": "*", + "jsonfile": "*" + } +}