const minimist = require('minimist');


class KabaCli
{
    /**
     * @param {Object} cliArgv
     */
    constructor (cliArgv)
    {
        const argv = minimist(cliArgv, {
            boolean: ["dev", "d", "h", "help", "v", "version"],
        });

        /**
         * @private
         * @type {boolean}
         */
        this.dev = argv.d || argv.dev;

        /**
         * @private
         * @type {boolean}
         */
        this.version = argv.v || argv.version;

        /**
         * @private
         * @type {boolean}
         */
        this.help = argv.h || argv.help;
    }


    /**
     * Returns whether this is a dev build
     *
     * @return {boolean}
     */
    isDev ()
    {
        return this.dev;
    }

    /**
     * Returns whether the version info should be shown
     *
     * @return {boolean}
     */
    showVersion ()
    {
        return this.version;
    }

    /**
     * Returns whether the help should be shown
     *
     * @return {boolean}
     */
    showHelp ()
    {
        return this.help;
    }
}

module.exports = new KabaCli(process.argv.slice(2));

const minimist = require('minimist');


class KabaCli
{
    /**
     * @param {Object} cliArgv
     */
    constructor (cliArgv)
    {
        const argv = minimist(cliArgv, {
            boolean: [
                // dev = debug + watch + sourceMaps
                "dev",
                "d",

                // debug
                "debug",

                // sourceMaps
                "with-sourcemaps",
                "with-source-maps",

                // watch
                "watch",

                // help
                "h",
                "help",

                // version
                "v",
                "version",
            ],
        });

        /**
         * @private
         * @type {boolean}
         */
        this.dev = argv.d || argv.dev;

        /**
         * @private
         * @type {boolean}
         */
        this.debug = argv.debug;

        /**
         * @private
         * @type {boolean}
         */
        this.sourceMaps = argv["with-sourcemaps"] || argv["with-source-maps"];

        /**
         * @private
         * @type {boolean}
         */
        this.watch = argv.watch;

        /**
         * @private
         * @type {boolean}
         */
        this.help = argv.h || argv.help;

        /**
         * @private
         * @type {boolean}
         */
        this.version = argv.v || argv.version;
    }


    /**
     * Returns whether this is a debug build
     *
     * @return {boolean}
     */
    isDebug ()
    {
        return this.debug || this.dev;
    }


    /**
     * Returns whether to include sourcemaps
     *
     * @return {boolean}
     */
    includeSourceMaps ()
    {
        return this.sourceMaps || this.dev;
    }


    /**
     * Returns whether the watcher should be activated
     *
     * @return {boolean}
     */
    isWatch ()
    {
        return this.watch || this.dev;
    }


    /**
     * Returns whether the help should be shown
     *
     * @return {boolean}
     */
    showHelp ()
    {
        return this.help;
    }


    /**
     * Returns whether the version info should be shown
     *
     * @return {boolean}
     */
    showVersion ()
    {
        return this.version;
    }
}

module.exports = new KabaCli(process.argv.slice(2));

Update CLI interface