Skip to content

Commit

Permalink
Resolves #1, #2, #3 and #4
Browse files Browse the repository at this point in the history
  • Loading branch information
hadesbox committed Nov 3, 2014
1 parent 16a3afe commit c1ffa86
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 26 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@ Simple-CLI-ramlparser

A simple implementation of a raml parser with the raml-js library.

To install simply run
To install it simply run

$sudo ./install.sh
$ sudo npm install -g

this will put a ramlparser program on your PATH.
this will fetch all packages (npm install), and create the executable to your PATH (ramlparser). Then you can globally call the parser like this

$ ramlparser spec.raml
$ ramlparser /path/to/spec.raml

Alternatively you can manually install it by

$ npm install

and then execute it as:

$ ./raml-parser.js /path/to/spec.raml

# Requirements

You need to have nodejs installed (and npm) to build this program libraries.
12 changes: 0 additions & 12 deletions install.sh

This file was deleted.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{
"name": "simple-ramlparser",
"name": "ramlparser",
"version": "0.0.1",
"author": "Luix <[email protected]>",
"description": "a simple CLI parser for raml files",
"scripts": {},
"main" : "raml-parser.js",
"dependencies" : {
"colors" : "*",
"raml-parser" : "*"
}
},
"bin": {
"ramlparser": "raml-parser.js"
},
"preferGlobal": true
}
17 changes: 8 additions & 9 deletions raml-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@

var raml = require('raml-parser');
var fs = require("fs");
var colors = require("colors");

if(process.argv.length < 3){
console.error("Error".red, "Not enough parameters".cyan);
console.error("usage:", "ramlparser".blue, "input.raml".green);
console.error("Error", "Not enough parameters");
console.error("usage:", "ramlparser", "input.raml");
process.exit(-1);
}

var input_file = process.argv[2];

if(input_file=="" || !fs.existsSync(input_file)){
console.error("Error".red, "Invalid or empty input file".cyan, input_file);
console.error("Error", "Invalid or empty input file", input_file);
process.exit(-1);
}
else{
console.log("Parsing".cyan, input_file, "...".cyan);
console.log("Parsing", input_file, "...");
raml.loadFile(input_file).then(function(data) {
console.log("your RAML file is correct!".green)
console.log("your RAML file is correct!")
}, function(error) {
console.error("Error while parsing your file".red, error.message.cyan);
console.error("Error while parsing your file, ", error.message);
console.error("at", error.problem_mark.name);
console.error("line:", error.problem_mark.line, "column:", error.problem_mark.column);
});
}


0 comments on commit c1ffa86

Please sign in to comment.