-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fmt: deno fmt -
formats stdin and print to stdout
#3920
Conversation
I think it's common to use |
@nayeemrmn That’s also an option. Love to get more feedback also from others |
How about without the flag? If no files input then read from pipe? |
agree. see what I wrote before Lines 548 to 564 in 8bc639a
|
Hmm, we may want to have a default glob for this case. |
Sorry I'm a beginner at rust 😅If there are no arguments couldn't you check stdin().lines() first before pushing **/*? The flag is fine too. |
cli/flags.rs
Outdated
.arg( | ||
Arg::with_name("stdin") | ||
.long("stdin") | ||
.help("Read the code from stdin.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like besides reading from stdin it outputs code to stdout. Can you describe this behavior in help text? (Maybe add an example to subcommand as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another reason -
would be better. The meaning of this functionality is specifically "stdin
/stdout
". This is conventionally represented with -
, whereas --stdin
is misleading. I feel more strongly about it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nayeemrmn -
can be a valid filename. (nah I'm just joking + bikeshedding here)
Yeah --stdin
is a bit long to type and its implicit effect on stdout is definitely slightly confusing... If @bartlomieju also thinks -
is better then it is a very easy change to make.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, SGTM, if that's an easy change I guess it makes more sense - we already have similar argument in catj
.
@ry and I had a talk about it - we're not happy with current glob solution and are thinking about removing it entirely for now. Glob crates available in Rust have completely different functionality (and it seems syntax too) than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one nitpick
deno fmt -
formats stdin and print to stdout
d55a5b9
to
56de22f
Compare
Closes #3877
Add--stdin
flag (also compatible with--check
) to format stdin inputdeno fmt -
now reads from stdin and prints output to stdout.