Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/akiojin/argument-builder


https://github.com/akiojin/argument-builder

Last synced: 20 days ago
JSON representation

Awesome Lists containing this project

README

        

# argument-builder
This package implements a class that creates command line parameters.

## Usage
```js
import { ArgumentBuilder } from '@akiojin/argument-builder'
```
```js
const builder = new ArgumentBuilder()
builder
.Append('--verbose')
.Append('--file', 'log.txt')
.Append([ '--output', './out' ])
await execa.execa('foo', builder.Build())
```

## Reference
### class `ArgumentBuilder`
#### `Append(arg: string | string[], param?: string): ArgumentBuilder`
##### Description
Add an argument.

##### Arguments
|Name|Type|Description|
|:--|:--|:--|
|`arg`|`string` \| string[]|Commands to pass to command line|
|`param?`|`string`|Parameters to be added to the command|

##### Return
|Type|Description|
|:--|:--|
|`ArgumentBuilder`|Return this|

#### `Count(): number`
##### Description
Returns the number of arguments added.

##### Return
|Type|Description|
|:--|:--|
|`number`|Number of arguments|

#### `Build(): string[]`
##### Description
Returns an array of arguments to be passed to the command line.

##### Return
|Type|Description|
|:--|:--|
|`string[]`|Argument array|

#### `ToString(): string`
##### Description
Return arguments as a single space-delimited string

##### Return
|Type|Description|
|:--|:--|
|`string`|Return arguments as a single space-delimited string|