diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..a2a1cb5 --- /dev/null +++ b/install.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +echo installing node libraries ... raml-parser +npm install + +echo creating link on /usr/bin... raml-parser +ln -s $(pwd)/raml-parser.js /usr/bin/ramlparser + +echo setting permissions... +chmod +x $(pwd)/raml-parser.js + +echo all done... \ No newline at end of file diff --git a/package.json b/package.json new file mode 100755 index 0000000..74a6b9e --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "simple-ramlparser", + "version": "0.0.1", + "author": "Luix ", + "description": "a simple CLI parser for raml files", + "scripts": {}, + "dependencies" : { + "colors" : "*", + "raml-parser" : "*" + } +} diff --git a/raml-parser.js b/raml-parser.js new file mode 100755 index 0000000..b0a27b6 --- /dev/null +++ b/raml-parser.js @@ -0,0 +1,28 @@ +#!/usr/bin/env node + +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); + 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); + process.exit(-1); +} +else{ + console.log("Parsing".cyan, input_file, "...".cyan); + raml.loadFile(input_file).then(function(data) { + console.log("your RAML file is correct!".green) + }, function(error) { + console.error("Error while parsing your file".red, error.message.cyan); + }); +} + +