enhance

ac-apps-minimal-enhance-argv

enhance/argv.js

Read command line arguments and parse only the required ones. Arguments can be specified in key=value format. Example: airtable-api-key=XXXXXXXX_XXXXXXXXX airtable-base-name=XXXXXXXX … The arguments are further checked and verified by the needed scripts.

A module for ac-bundle-app, published by ac-bundle-module. namespace: ac-apps-minimal

Install from:

https://www.npmjs.com/package/ac-apps-minimal-enhance-argv
https://github.com/animatedcreativity/ac-apps-minimal-enhance-argv

Available Methods: start

start

function() {
  app.parseArgv = function(list) {
    var options = {};
    for (var i=2; i<=process.argv.length-1; i++) {
      var option = process.argv[i];
      var name = option.split("=").shift().trim();
      var cName = app.camelCase(name).split("-").join("");
      var value = option.split("=").pop().trim();
      if (list.indexOf(name) >= 0) {
        options[cName] = value;
      } else {
        console.log(app.consoleColors.bgRed, "Invalid option: " + name);
        return;
      }
    }
    app.cliOptions = options;
    return options;
  };
}

Happy Coding!

MIT License: https://choosealicense.com/licenses/mit/

Copyright 2022 Animated Creativity

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Leave a Reply

Your email address will not be published. Required fields are marked *