comparison jet-symbols/src/JetBrains.CommandLine.Symbols/Program.cs @ 102:0e927b14ccf1

restored jet-symbols native tool sources
author Evgeniy.Koshkin@unit-519.Labs.IntelliJ.Net
date Mon, 16 May 2016 19:40:51 +0300
parents
children
comparison
equal deleted inserted replaced
101:52fc27842bc1 102:0e927b14ccf1
1 // Decompiled with JetBrains decompiler
2 // Type: JetBrains.CommandLine.Symbols.Program
3 // Assembly: JetBrains.CommandLine.Symbols, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325
4 // MVID: EF046BF6-60AC-48EA-9121-8AF3D8D08853
5 // Assembly location: C:\Data\Work\TeamCity\misc\tc-symbol-server\tools\JetSymbols\JetBrains.CommandLine.Symbols.exe
6
7 using JetBrains.Util;
8 using System;
9 using System.Collections.Generic;
10 using System.IO;
11 using System.Linq;
12 using System.Text;
13
14 namespace JetBrains.CommandLine.Symbols
15 {
16 internal static class Program
17 {
18 private const int ERROR_EXIT_CODE = 1;
19
20 public static int Main(string[] args)
21 {
22 try
23 {
24 string error;
25 ICommand commandToExecute = Program.GetCommandToExecute(args, out error);
26 if (commandToExecute != null)
27 return commandToExecute.Execute();
28 Program.PrintIncorrectUsageMessage(error);
29 return 1;
30 }
31 catch (Exception ex)
32 {
33 Console.Error.WriteLine((object) ex);
34 return 1;
35 }
36 }
37
38 private static ICommand GetCommandToExecute(string[] args, out string error)
39 {
40 error = string.Empty;
41 string str = ((IEnumerable<string>) args).First<string>();
42 FileSystemPath inputFilePath = FileSystemPath.TryParse(args[2].Substring(3));
43 FileSystemPath outputFilePath = FileSystemPath.TryParse(args[1].Substring(3));
44 IEnumerable<FileSystemPath> targetFilePaths = Program.LoadPathsFromFile(inputFilePath);
45 switch (str)
46 {
47 case "dumpSymbolSign":
48 return (ICommand) new DumpSymbolsFileSignCommand(outputFilePath, targetFilePaths);
49 case "dumpBinSign":
50 return (ICommand) new DumpBinaryFileSignCommand(outputFilePath, targetFilePaths);
51 default:
52 error = string.Format("{0} command is unknown.", (object) str);
53 return (ICommand) null;
54 }
55 }
56
57 private static IEnumerable<FileSystemPath> LoadPathsFromFile(FileSystemPath inputFilePath)
58 {
59 ICollection<FileSystemPath> result = (ICollection<FileSystemPath>) new HashSet<FileSystemPath>();
60 inputFilePath.ReadTextStream((Action<StreamReader>) (streamReader =>
61 {
62 while (!streamReader.EndOfStream)
63 {
64 FileSystemPath fileSystemPath = FileSystemPath.TryParse(streamReader.ReadLine());
65 if (!fileSystemPath.IsEmpty)
66 result.Add(fileSystemPath);
67 }
68 }), (Encoding) null);
69 return (IEnumerable<FileSystemPath>) result;
70 }
71
72 private static void PrintIncorrectUsageMessage(string error)
73 {
74 Console.Error.WriteLine(error);
75 Console.Error.WriteLine("Usage: Symbols /<command_name> <command_parameters>");
76 }
77 }
78 }