@hugojosefson/example-cli
v4.0.1
Published
Example Node.js CLI app.
Downloads
6
Maintainers
Readme
Node.js example CLI app
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