@hugojosefson/example-cli

    4.0.1 • Public • Published

    Node.js example CLI app

    Build Status npm page License MIT SemVer 2.0.0 JavaScript Style Guide

    Introduction

    This is a simple CLI app in Node.js, using ES Modules.

    Using as a template

    To use this project as a template for your own project, you can do this:

    mkdir my-cli
    cd my-cli
    git init
    curl https://codeload.github.com/hugojosefson/nodejs-example-cli/tar.gz/master | tar xzv --strip-components=1
    git add --all
    git commit -m 'Add template files from nodejs-example-cli.'
    yarn

    You may wish to make it more your own project:

    export GITHUB_REPO='xxxx/yyyy'   # replace with your project's github repo 
    export BIN_NAME='yyyy'           # replace with name of main binary 
    export NPM_NAME='@xxxx/yyyy'     # optional: your project's npm name 
     
    npx replace '"version": "[^"]+"'              '"version": "0.0.1"'       package.json
    npx replace '"description": "[^"]+"'          '"description": ""'        package.json
    npx replace '"author": "[^"]+"'               '"author": ""'             package.json
    npx replace '@hugojosefson/example-cli'       "${NPM_NAME:-${BIN_NAME}}" . --recursive
    npx replace 'hugojosefson/nodejs-example-cli' "${GITHUB_REPO}"           . --recursive
    npx replace 'example-cli'                     "${BIN_NAME}"              . --recursive
    npx replace '^#+ Using as [\S\s]+(## P(re)+)' '$1'                       README.md
    npx replace '"keywords":[^\]]*\][^"]*'        ''                         package.json
    rm CHANGELOG.md
    yarn
     
    git add --all
    git commit -m "Rename project to ${NPM_NAME}."

    Then edit package.json and go on developing!

    Prerequisite

    Node.js, v13.2.0 or higher, ideally at least v14.0.0.

    Recommended to install latest via nvm:

    nvm install stable

    Usage

    npx --package @hugojosefson/example-cli example-cli greet "Your Name"

    Will say hello to you.

    Programmatic access

    You can also import the module, and use its exported functions programmatically.

    API

    identity

    Returns the supplied argument.

    Parameters
    • a any Any argument.

    Returns any The argument a.

    generateGreeting

    Generates a greeting.

    Parameters
    • options Object
      • options.whom string Whom to greet.
      • options.language string Optional. Language of greeting, en or sv. Default en.

    Returns Promise<string> A Promise of a greeting.

    Install

    npm i @hugojosefson/example-cli

    DownloadsWeekly Downloads

    10

    Version

    4.0.1

    License

    MIT

    Unpacked Size

    267 kB

    Total Files

    12

    Last publish

    Collaborators

    • hugojosefson