Skip to content

Commit

Permalink
Categorize all options
Browse files Browse the repository at this point in the history
  • Loading branch information
gkoberger committed Oct 4, 2016
1 parent e673cc1 commit 9c2a1a5
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 6 deletions.
1 change: 1 addition & 0 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ exports.load = function(action) {

console.log('Action not found.'.red);
console.log('Type ' + 'api help'.yellow + ' to see all commands');
process.exit();
};

function exampleId(file, apiId) {
Expand Down
3 changes: 2 additions & 1 deletion lib/docs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
exports.swagger = true;
exports.swaggerUrl = true;
exports.login = true;
exports.desc = "Upload your docs to ReadMe.io";
exports.category = "services";
exports.desc = "Upload your docs to ReadMe ($)";

exports.run = function(config, info) {
console.log('Uploading Swagger file...');
Expand Down
1 change: 1 addition & 0 deletions lib/generate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
exports.swagger = true;
exports.login = false;
exports.desc = "Output your Swagger file";
exports.category = "utility";

exports.run = function(config, info) {
console.log(JSON.stringify(info.swagger, undefined, 2));
Expand Down
35 changes: 31 additions & 4 deletions lib/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,45 @@ var _ = require('lodash');

exports.swagger = false;
exports.login = false;
exports.category = "basic";
exports.desc = "Learn what you can do with api";

exports.run = function(config, info) {
console.log("");
console.log("Here's a list of what you can do with " + 'api'.yellow + ":");
console.log("");
console.log("Usage: api <command> [swagger url]");
var files = glob.sync(path.join(__dirname, "*"));

var categories = {
'basic': {
desc: 'Commands for getting started',
commands: [],
},
'services': {
desc: 'Hosted third-party services ' + '(Will post to the Internet)'.grey,
commands: [],
},
'utility': {
desc: 'Utility functions for working locally',
commands: [],
},
};

_.each(files, function(file) {
var action = file.match(/(\w+).js/)[1];
var info = require(file).desc || "";
console.log(" $".grey + pad(" api " + action) + " " + info.grey);
var f = require(file);
var info = f.desc || "";

if(f.category) {
categories[f.category].commands.push(" $".grey + pad(" api " + action) + " " + info.grey);
}
});

_.each(categories, function(category) {
console.log("");
console.log(category.desc);
_.each(category.commands, function(command) {
console.log(command);
});
});

console.log("");
Expand Down
3 changes: 2 additions & 1 deletion lib/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ exports.swagger = true;
exports.swaggerUrl = true;
exports.login = true;
exports.desc = "Get a public URL for your API";
exports.category = "services";

exports.run = function(config, info) {
console.log("");
console.log("Success! ".green + "You can now access your Swagger from the following public URL:");
console.log("Success! ".green + "You can now access your Swagger from the following publicly sharable URL:");
console.log("");
console.log(" " + info.swaggerUrl);
console.log("");
Expand Down
1 change: 1 addition & 0 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var utils = require('../utils');

exports.swagger = false;
exports.login = false;
exports.category = "basic";
exports.desc = "Create a new API specification";

var types = [
Expand Down
1 change: 1 addition & 0 deletions lib/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var open = require('open');
exports.swagger = false;
exports.login = false;
exports.desc = "Authenticate this computer";
exports.category = "utility";

exports.run = function(config, info) {
if(info.args[1] == 'info') {
Expand Down
1 change: 1 addition & 0 deletions lib/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var request = require('request');

exports.swagger = true;
exports.login = true;
exports.category = "services";
exports.desc = "Run a mock server based on your API";

exports.run = function(config, info) {
Expand Down

0 comments on commit 9c2a1a5

Please sign in to comment.