Skip to content

Commit

Permalink
initial layout, arg parsing and main
Browse files Browse the repository at this point in the history
  • Loading branch information
gsjurseth committed Feb 25, 2015
1 parent 03189ce commit 17f53f2
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -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' );
}
15 changes: 15 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -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) );
}
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"license": "MIT",
"dependencies": {
"argv-parser": "*",
"util": "*",
"jsonfile": "*"
}
}

0 comments on commit 17f53f2

Please sign in to comment.