File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,8 @@ dyt --record | wc -w
177177
178178Copying to the clipboard can be suppressed with the ` --no-clipboard ` option.
179179
180+ Output may be redirected to a file with the ` --output ` flag.
181+
180182### Smoke test
181183
182184Verify your mic works without needing the daemon:
Original file line number Diff line number Diff line change 1+ use std:: fs:: File ;
2+ use std:: io:: Write ;
3+ use std:: path:: PathBuf ;
4+
15use dyt_cli:: { capture, encode, transport} ;
26
37use anyhow:: Result ;
@@ -17,6 +21,10 @@ struct Cli {
1721 /// Suppress copying text to the clipboard.
1822 #[ arg( long) ]
1923 no_clipboard : bool ,
24+
25+ /// Write to an output file. Defaults to stdout.
26+ #[ arg( long) ]
27+ output : Option < PathBuf > ,
2028}
2129
2230fn main ( ) -> Result < ( ) > {
@@ -43,8 +51,13 @@ fn main() -> Result<()> {
4351 eprintln ! ( "Copied to clipboard." ) ;
4452 }
4553
46- // Also print to stdout for piping
47- print ! ( "{text}" ) ;
54+ if let Some ( output) = cli. output {
55+ let mut fout = File :: open ( output) ?;
56+ write ! ( fout, "{text}" ) ?;
57+ } else {
58+ // Also print to stdout for piping
59+ print ! ( "{text}" ) ;
60+ }
4861
4962 Ok ( ( ) )
5063}
You can’t perform that action at this time.
0 commit comments