summaryrefslogtreecommitdiff
path: root/cli/flags.rs
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2020-02-09 02:19:05 -0800
committerGitHub <noreply@github.com>2020-02-09 11:19:05 +0100
commit506601841218fe34a744c8fce0f1011c716bdc73 (patch)
tree1b80e06ec5cd1385ea4aaabb060b83701d47b4bb /cli/flags.rs
parent1c0ffa138355c7eb90fd5d3c01f799245636bcc0 (diff)
fmt: `deno fmt -` formats stdin and print to stdout (#3920)
Diffstat (limited to 'cli/flags.rs')
-rw-r--r--cli/flags.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 748a7f95e..a8c51093e 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -550,7 +550,10 @@ fn fmt_subcommand<'a, 'b>() -> App<'a, 'b> {
deno fmt myfile1.ts myfile2.ts
- deno fmt --check",
+ deno fmt --check
+
+ # Format stdin and write to stdout
+ cat file.ts | deno fmt -",
)
.arg(
Arg::with_name("check")
@@ -1390,6 +1393,18 @@ mod tests {
..DenoFlags::default()
}
);
+
+ let r = flags_from_vec_safe(svec!["deno", "fmt"]);
+ assert_eq!(
+ r.unwrap(),
+ DenoFlags {
+ subcommand: DenoSubcommand::Format {
+ check: false,
+ files: None
+ },
+ ..DenoFlags::default()
+ }
+ );
}
#[test]