File tree Expand file tree Collapse file tree 2 files changed +42
-4
lines changed
Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -12,16 +12,53 @@ var isatty = require('tty').isatty
1212
1313var usingConsole = isatty ( 1 ) && isatty ( 2 ) ;
1414
15- process . stdin . pipe ( new FeedParser ( ) )
15+ var argv = require ( 'mri' ) ( process . argv . slice ( 2 ) , {
16+ alias : {
17+ u : 'feedurl' ,
18+ g : 'group' ,
19+ j : 'json'
20+ } ,
21+ boolean : [
22+ 'normalize' ,
23+ 'addmeta' ,
24+ 'resume_sax_error' ,
25+ 'json'
26+ ] ,
27+ default : {
28+ normalize : true ,
29+ addmeta : true ,
30+ resume_saxerror : true ,
31+ json : ! usingConsole
32+ }
33+ } ) ;
34+
35+ var items = [ ] ;
36+
37+ process . stdin . pipe ( new FeedParser ( argv ) )
1638 . on ( 'error' , console . error )
1739 . on ( 'readable' , function ( ) {
1840 var stream = this , item ;
1941 while ( item = stream . read ( ) ) {
20- if ( usingConsole ) {
21- console . log ( util . inspect ( item , null , 10 , true ) ) ;
42+ if ( argv . group ) {
43+ items . push ( item ) ;
44+ }
45+ else {
46+ if ( argv . json ) {
47+ console . log ( JSON . stringify ( item ) ) ;
48+ }
49+ else {
50+ console . log ( util . inspect ( item , null , 10 , true ) ) ;
51+ }
52+ }
53+ }
54+ } )
55+ . on ( 'end' , function ( ) {
56+ if ( argv . group ) {
57+ if ( argv . json ) {
58+ console . log ( JSON . stringify ( items ) ) ;
2259 }
2360 else {
24- console . log ( JSON . stringify ( item ) ) ;
61+ console . log ( util . inspect ( items , null , 10 , true ) ) ;
2562 }
2663 }
2764 } ) ;
Original file line number Diff line number Diff line change 4141 "lodash.get" : " ^4.4.2" ,
4242 "lodash.has" : " ^4.5.2" ,
4343 "lodash.uniq" : " ^4.5.0" ,
44+ "mri" : " ^1.1.0" ,
4445 "readable-stream" : " ^2.2.2" ,
4546 "sax" : " ^1.2.4"
4647 },
You can’t perform that action at this time.
0 commit comments