File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ use clap::Parser;
2
2
3
3
use crate :: github_repo:: GitHubRepo ;
4
4
5
+ pub const STDIN : & str = "-" ;
6
+
5
7
#[ derive( Debug , Parser ) ]
6
8
#[ command( author, version, about, long_about = None ) ]
7
9
pub struct Args {
@@ -19,4 +21,7 @@ pub struct Args {
19
21
20
22
#[ arg( long, value_delimiter = ',' ) ]
21
23
pub repos : Vec < GitHubRepo > ,
24
+
25
+ #[ arg( long, short, default_value = STDIN ) ]
26
+ pub output : String ,
22
27
}
Original file line number Diff line number Diff line change @@ -5,11 +5,15 @@ mod github_repo;
5
5
mod package_json;
6
6
mod vpm;
7
7
8
- use std:: io ;
8
+ use std:: { fs :: File , io } ;
9
9
10
10
use clap:: Parser ;
11
11
12
- use crate :: { args:: Args , cache:: Cache , generator:: VpmRepoGenerator } ;
12
+ use crate :: {
13
+ args:: { Args , STDIN } ,
14
+ cache:: Cache ,
15
+ generator:: VpmRepoGenerator ,
16
+ } ;
13
17
14
18
#[ tokio:: main]
15
19
async fn main ( ) -> Result < ( ) , anyhow:: Error > {
@@ -32,7 +36,12 @@ async fn main() -> Result<(), anyhow::Error> {
32
36
33
37
cache. save ( ) ?;
34
38
35
- serde_json:: to_writer_pretty ( io:: stdout ( ) , & vpm_repos) ?;
39
+ if args. output . as_str ( ) == STDIN {
40
+ serde_json:: to_writer_pretty ( io:: stdout ( ) , & vpm_repos) ?;
41
+ } else {
42
+ let f = File :: create ( & args. output ) ?;
43
+ serde_json:: to_writer_pretty ( f, & vpm_repos) ?;
44
+ }
36
45
37
46
Ok ( ( ) )
38
47
}
You can’t perform that action at this time.
0 commit comments