Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

vipera-npm-registry / de-doc-generator   js

Repository URL to install this package:

Version: 1.0.0 

/ bin / cli / help.js

/**
 * Created by marcobonati on 15/05/2017.
 */
/**
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 */
var fs = require('fs'),
    Q = require('q'),
    path = require('path');

module.exports = function help (args) {
    var command,
        file,
        raw,
        docdir;

    var command = args.argv.original[0];
    if (command){
        if (command.startsWith('--')){
            command =  command.substring(2, command.length);
        } else if (command.startsWith('-')){
            command =  command.substring(1, command.length);
        }
    } else {
        command = "de-doc-gen";
    }

    if (command==="help"){
        command = "de-doc-gen";
    }

    //console.log(args);
    console.log(command);

    docdir = path.join(__dirname, '../../', 'doc');
    file = path.join(docdir, command + '.txt');

    try {
        raw = fs.readFileSync(file).toString('utf8');
        console.log("");
        console.log(raw);
    } catch (ex){
        console.log("No help found for '" + command + "'");
    }
    return Q();
};