Fix typo in OIDs corresponding to SHA256, SHA384, and SHA512 (#21707)
[mono-project.git] / mcs / tools / cil-strip / cilstrip.cs
blob97cd4669eecb50188ae428d5b9b46dd4a53d51ac
1 //
2 // mono-cil-strip
3 //
4 // Author(s):
5 // Jb Evain (jbevain@novell.com)
6 //
7 // Copyright (C) 2008 Novell, Inc (http://www.novell.com)
8 //
10 using System;
11 using System.Collections.Generic;
12 using System.Reflection;
14 using Mono.Cecil;
16 namespace Mono.CilStripper {
18 class Program {
19 static bool quiet;
20 static int Main (string [] arguments)
22 var args = new List<string> (arguments);
23 if (args.Count > 0 && args [0] == "-q") {
24 quiet = true;
25 args.RemoveAt (0);
27 Header ();
29 if (args.Count == 0)
30 Usage ();
32 string file = args [0];
33 string output = args.Count > 1 ? args [1] : file;
35 try {
36 AssemblyDefinition assembly = AssemblyFactory.GetAssembly (file);
37 StripAssembly (assembly, output);
39 if (!quiet) {
40 if (file != output)
41 Console.WriteLine ("Assembly {0} stripped out into {1}", file, output);
42 else
43 Console.WriteLine ("Assembly {0} stripped", file);
45 return 0;
46 } catch (TargetInvocationException tie) {
47 Console.WriteLine ("Error: {0}", tie.InnerException);
48 } catch (Exception e) {
49 Console.WriteLine ("Error: {0}", e);
51 return 1;
54 static void StripAssembly (AssemblyDefinition assembly, string output)
56 AssemblyStripper.StripAssembly (assembly, output);
59 static void Header ()
61 if (quiet)
62 return;
63 Console.WriteLine ("Mono CIL Stripper");
64 Console.WriteLine ();
67 static void Usage ()
69 Console.WriteLine ("Usage: mono-cil-strip [options] file [output]");
70 Console.WriteLine (" -q Only output errors.");
71 Environment.Exit (1);