forked from tech-srl/code2vec
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
56 lines (49 loc) · 1.55 KB
/
Program.cs
File metadata and controls
56 lines (49 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using CommandLine;
using CommandLine.Text;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Extractor
{
class Program
{
static List<String> ExtractSingleFile(string filename, Options opts)
{
string data = File.ReadAllText(filename);
var extractor = new Extractor(data, opts);
List<String> result = extractor.Extract();
return result;
}
static void Main(string[] args)
{
Options options = new Options();
Parser.Default.ParseArguments<Options>(args)
.WithParsed(opt => options = opt)
.WithNotParsed(errors =>
{
Console.WriteLine(errors);
return;
});
string path = options.Path;
string[] files;
if (Directory.Exists(path))
{
files = Directory.GetFiles(path, "*.cs", SearchOption.AllDirectories);
}
else
{
files = new string[] { path };
}
IEnumerable<string> results = null;
results = files.AsParallel().WithDegreeOfParallelism(options.Threads).SelectMany(filename => ExtractSingleFile(filename, options));
using (StreamWriter sw = new StreamWriter(options.OFileName, append: true))
{
foreach (var res in results)
{
sw.WriteLine(res);
}
}
}
}
}