Skip to content

Latest commit

 

History

History
309 lines (167 loc) · 5.7 KB

ShellReturnValueNJS.md

File metadata and controls

309 lines (167 loc) · 5.7 KB

nodejsscriptDocs


nodejsscript / s / ShellReturnValueNJS

Interface: ShellReturnValueNJS

Extends

Properties

xargs

xargs: XargsFunction


$

$: DollarFunction


run

run: RunFunction


runA

runA: RunAsyncFunction


read()

read: (options) => Promise<ShellString>

This function mimic read command. So, the function purpose is reading from stdin.

const answer= await $.read({ "-p": "Question" });
const color= await $.read({ "-p": "Your color", completions: [ "red", "green" ] });
if($.isFIFO(0)) await $.read().then(echo.bind(null, "E.g. for reading received input:"));

Parameters

options: ReadOptions

Returns

Promise<ShellString>


cat

cat: CatFunction

Returns a string containing the given pipeline, or a concatenated string containing the pipelines if more than one input stream is given (a new line character is introduced between each input).

Returns

A string containing the given pipeline, or a concatenated string containing the pipelines if more than one input stream is given (a new line character is introduced between each input).

Inherited from

ShellReturnValue.cat


exec

exec: ExecFunction

Executes the given command.

Param

The command to execute.

Param

Silence and synchronous options.

Param

Receives code and output asynchronously.

Returns

Returns an object containing the return code and output as string, or if {async: true} or a callback was passed, a ChildProcess.

Inherited from

ShellReturnValue.exec


head

head: HeadFunction

Read the start of a pipeline input.

Inherited from

ShellReturnValue.head


grep

grep: GrepFunction

Reads input string from given files and returns a string containing all lines of the file that match the given regex_filter. Wildcard * accepted.

Param

Available options: - -v: Inverse the sense of the regex and print the lines not matching the criteria. - -l: Print only filenames of matching files

Param

The regular expression to use.

Returns

Returns a string containing all lines of the file that match the given regex_filter.

Inherited from

ShellReturnValue.grep


sed

sed: SedFunction

Reads an input string from pipeline and performs a JavaScript replace() on the input using the given search regex and replacement string or function.

Param

Available options: - -i: Replace contents of 'file' in-place. Note that no backups will be created!

Param

The regular expression to use for search.

Param

The replacement.

Returns

The new string after replacement.

Inherited from

ShellReturnValue.sed


sort

sort: SortFunction

Return the contents of the pipeline, sorted line-by-line.

Param

Available options: - -r: Reverse the results - -n: Compare according to numerical value

Inherited from

ShellReturnValue.sort


tail

tail: TailFunction

Read the end of a pipeline input.

Inherited from

ShellReturnValue.tail


uniq

uniq: UniqFunction

Filter adjacent matching lines from input.

Param

Available options: - -i: Ignore case while comparing - -c: Prefix lines by the number of occurrences - -d: Only print duplicate lines, one for each group of identical lines

Inherited from

ShellReturnValue.uniq


code

code: number

The process exit code.

Inherited from

ShellReturnValue.code


stdout

stdout: string

The process standard output.

Inherited from

ShellReturnValue.stdout


stderr

stderr: string

The process standard error output.

Inherited from

ShellReturnValue.stderr

Methods

to()

to(file): void

Analogous to the redirection operator > in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc).

Like Unix redirections, to() will overwrite any existing file!

Parameters

file: string

The file to use.

Returns

void

Inherited from

ShellReturnValue.to


toEnd()

toEnd(file): void

Analogous to the redirect-and-append operator >> in Unix, but works with JavaScript strings (such as those returned by cat, grep, etc).

Parameters

file: string

The file to append to.

Returns

void

Inherited from

ShellReturnValue.toEnd