1- using Semmle . Util . Logging ;
21using System . Collections . Generic ;
32using System . IO ;
43using System . Linq ;
54using Semmle . Util ;
5+ using Semmle . Util . Logging ;
66
77namespace Semmle . Extraction . PowerShell . Standalone
88{
@@ -36,22 +36,31 @@ public override bool HandleOption(string key, string value)
3636 case "exclude" :
3737 Excludes . Add ( value ) ;
3838 return true ;
39+ case "file-list" :
40+ Files = File . ReadAllLines ( value ) . Select ( f => new FileInfo ( f ) ) . ToArray ( ) ;
41+ return true ;
3942 default :
4043 return base . HandleOption ( key , value ) ;
4144 }
4245 }
4346
4447 public override bool HandleArgument ( string arg )
4548 {
46- SrcDir = arg ;
47- if ( ! new FileInfo ( SrcDir ) . Exists )
49+ if ( ! new FileInfo ( arg ) . Exists )
4850 {
49- var di = new DirectoryInfo ( SrcDir ) ;
51+ var di = new DirectoryInfo ( arg ) ;
5052 if ( ! di . Exists )
5153 {
52- System . Console . WriteLine ( "Error: The file or directory {0} does not exist" , di . FullName ) ;
54+ System . Console . WriteLine (
55+ "Error: The file or directory {0} does not exist" ,
56+ di . FullName
57+ ) ;
5358 Errors = true ;
5459 }
60+ else
61+ {
62+ Files = di . GetFiles ( "*.*" , SearchOption . AllDirectories ) ;
63+ }
5564 }
5665 return true ;
5766 }
@@ -70,12 +79,17 @@ public override void InvalidArgument(string argument)
7079 /// <summary>
7180 /// Files/patterns to exclude.
7281 /// </summary>
73- public IList < string > Excludes { get ; } = new List < string > ( ) { "node_modules" , "bower_components" } ;
82+ public IList < string > Excludes { get ; } =
83+ new List < string > ( ) { "node_modules" , "bower_components" } ;
7484
7585 /// <summary>
7686 /// The directory or file containing the source code;
7787 /// </summary>
78- public string SrcDir { get ; set ; } = Directory . GetCurrentDirectory ( ) ;
88+ public FileInfo [ ] Files { get ; set ; } =
89+ new DirectoryInfo ( Directory . GetCurrentDirectory ( ) ) . GetFiles (
90+ "*.*" ,
91+ SearchOption . AllDirectories
92+ ) ;
7993
8094 /// <summary>
8195 /// Whether the extraction phase should be skipped (dry-run).
@@ -109,19 +123,20 @@ public bool ExcludesFile(string path)
109123 /// </summary>
110124 public static void ShowHelp ( System . IO . TextWriter output )
111125 {
112- output . WriteLine ( "PowerShell# standalone extractor\n \n Extracts PowerShell scripts in the current directory.\n " ) ;
126+ output . WriteLine (
127+ "PowerShell# standalone extractor\n \n Extracts PowerShell scripts in the current directory.\n "
128+ ) ;
113129 output . WriteLine ( "Additional options:\n " ) ;
114130 output . WriteLine ( " <path> Use the provided path instead." ) ;
115- output . WriteLine ( " --exclude:xxx Exclude a file or directory (can be specified multiple times)" ) ;
131+ output . WriteLine (
132+ " --exclude:xxx Exclude a file or directory (can be specified multiple times)"
133+ ) ;
116134 output . WriteLine ( " --dry-run Stop before extraction" ) ;
117135 output . WriteLine ( " --threads:nnn Specify number of threads (default=CPU cores)" ) ;
118136 output . WriteLine ( " --verbose Produce more output" ) ;
119-
120137 }
121138
122- private Options ( )
123- {
124- }
139+ private Options ( ) { }
125140
126141 public static Options Create ( string [ ] args )
127142 {
0 commit comments