Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

POSIX compliant pipe argument parser for node CLI apps

License

NotificationsYou must be signed in to change notification settings

gpestana/pipe-args

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

pipe

pipe-args adds support for unix piped arguments to your node CLI apps

pipe-args makes your node CLI apps to fully support unix pipelines, completelyout of the box. Require the the pipe-args module and all the piped arguments areadded to the process stdin transparently. It also integrates well with popularcommand line interface/parsers like yarg and commander.js.

Installation

$ npm install --save pipe-args

Usage

#!/usr/bin/env nodeconstpipe=require('pipe-args').load();console.log(`The piped arg is${process.argv[2]}`);
$echotest| node index.js$ The piped arg istest

Options

You can define which commands allow the stdin to be copied to process.argv bypassing them in theoptions object:

#!/usr/bin/env nodeconstpipe=require('pipe-args').load(['command']);console.log(`The piped arg is${process.argv[2]}`);
$echo OK| nodecommand index.js$ The piped arg is OK
$echo OK| node commandNotPiping index.js$ The piped arg is null // stdin was not parsed into process.argv

Integrations

pipe-args plays along with optstrings parsers such as yarg. The following yargsparser code:

#!/usr/bin/env nodeconstpipe=require('pipe-args').load();constyargs=require('yargs')constcli=yargs.demand(1)console.log(cli.argv);

parses linux-style piped arguments as expected:

$echo piped_arg| yargs-cli.js$ { _: ['piped_arg' ],'$0':'index.js' }

License:

MIT ©Gonçalo Pestana

About

POSIX compliant pipe argument parser for node CLI apps

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp