Skip to content

Commit 3b07903

Browse files
authored
docs: add example with args-tokenizer (#43)
As suggested in #42 added example to [args-tokenizer](https://github.com/TrySound/args-tokenizer) for parsing command and argument from strings.
1 parent 24e9861 commit 3b07903

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ proc.aborted; // true
124124
proc.killed; // true
125125
```
126126

127+
### Using with command strings
128+
129+
If you need to continue supporting commands as strings (e.g. "command arg0 arg1"),
130+
you can use [args-tokenizer](https://github.com/TrySound/args-tokenizer),
131+
a lightweight library for parsing shell command strings into an array.
132+
133+
```ts
134+
import {x} from 'tinyexec';
135+
import {tokenizeArgs} from 'args-tokenizer';
136+
137+
const commandString = 'echo "Hello, World!"';
138+
const [command, ...args] = tokenize(commandString);
139+
const result = await x(command, args);
140+
141+
result.stdout; // Hello, World!
142+
```
143+
127144
## API
128145

129146
Calling `x(command[, args])` returns an awaitable `Result` which has the

0 commit comments

Comments
 (0)