Comments (3)
Hi @oganexon,
What about using a normal option for specifying to read from stdin?
await new Command()
.option("-i, --stdin", "Read from stdin.")
.action(async ({ stdin }) => {
if (stdin) {
await Deno.copy(Deno.stdin, Deno.stdout);
}
})
.parse();
I'm not shure if we should implement it as an option. What about passing the -
as an argument to the action handler?
await new Command()
.argument("<input:string>", "Input file or - for reading from stdin.")
.action(async (_, input: string) => {
if (input === "-") {
await Deno.copy(Deno.stdin, Deno.stdout);
}
})
.parse();
from deno-cliffy.
await new Command() .argument("<input:string>", "Input file or - for reading from stdin.") .action(async (_, input: string) => { if (input === "-") { await Deno.copy(Deno.stdin, Deno.stdout); } }) .parse();
@c4spar This solution is just what I was looking for, thank you!
from deno-cliffy.
Hey @oganexon,
This solution was not yet working but it's fixed in v0.14.3 now.
I had a mistake in my previous example but here is a working one:
await new Command()
.arguments("<input:string>")
.action(async (_, input: string) => {
if (input === "-") {
await Deno.copy(Deno.stdin, Deno.stdout);
}
})
.parse();
from deno-cliffy.
Related Issues (20)
- Support for setup actions? HOT 12
- Incorrect validation error when parsing global flags mixed with sub-command flags HOT 9
- bug: version number is not printed using `-v` HOT 5
- Add env option to option method HOT 3
- Feedback wanted: Default prompt output to stderr HOT 4
- Make input/output stream configurable for all prompts
- Default validator/transform fail on Checkbox prompt with numeric or non-string values HOT 1
- How to include a boolean option in front of an argument
- Add hierarchical prompt select HOT 1
- completions command: "complete method" / "custom type" not working HOT 1
- disallow generating completions if name is not set HOT 2
- Feature: Support extracting options/args types from Command. HOT 4
- Enable customization of exit code for `required` env var HOT 2
- Site is down HOT 2
- show required options on usage
- flags without argument ('empty flags') are hard to use as boolean flag HOT 3
- Release cadence HOT 2
- Ordered/Ranked list prompt
- Table layout broken for various types of Unicode characters
- node support via dnt
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno-cliffy.