Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@untool/yargs

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@untool/yargs

untool yargs mixin

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
197
decreased by-25.38%
Maintainers
2
Weekly downloads
 
Created
Source

@untool/yargs

npm

@untool/yargs is a core mixin providing untool's actual command line interface, allowing other mixins to define their own commands. These custom commands will work exactly as those defined by untool's own modules and can be called using a local or global un executable.

Installation

$ yarn add @untool/yargs # OR npm install @untool/yargs

CLI

@untool/yargs can either be used with untool's global command line interface or directly, within package.json scripts of the project it is installed in: it locally installs an un command.

$ un
Usage: un <command> [options]

Commands:
  un serve    Serve foo
  un start    Build and serve foo
  un build    Build foo
  un develop  Serve foo in watch mode

Options:
  --version   Show version number                                     [boolean]
  --help, -h  Show help                                               [boolean]

$ un start
foo info
server listening at http://localhost:8080

@untool/yargs does not define any commands of its own, but takes care of basically setting up yargs and logging to stdout and stderr. You can call un with an optional -l or --log command line argument with one of the following values to control its output: debug, info, warn, error, silent

API

@untool/yargs exposes a couple of mixin hooks other mixins can implement, allowing them to alter or extend its functionality. These hooks will be called either by @untool/yargs itself or by others.

registerCommands(yargs, chalk) (pipe)

This is the most relevant hook provided by @untool/yargs: it enables other mixins to register their respective commands. Implementations of this mixin method will receive two arguments: a yargs instance and chalk to help you format your console output. Implementations need to return the yargs instance that they were called with.

const { Mixin } = require('@untool/core');

module.exports = class FooMixin extends Mixin {
  registerCommands(yargs) {
    return yargs.command({
      command: 'foo',
      handler: argv => {},
    });
  }
};

log{Debug,Info,Warn,Error}(...args) (override)

These are rather unusual mixin hooks, as they are basically utility methods that you can use in other mixins. They basically simply map to console.debug(), console.info(), console.warn(), console.error().

const { Mixin } = require('@untool/core');

module.exports = class FooMixin extends Mixin {
  foo() {
    const { logInfo } = this.core;
    logInfo('foo!');
  }
};

You can override the default implementation of these hooks by defining the appropriate methods in a custom @untool/core core mixin.

logStats(stats) (override)

This is yet another utility, aimed specifically at printing Webpack stats. It receives a stats object and its output to stdout is considered info. It uses console.info() under the hood.

Keywords

FAQs

Package last updated on 16 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc