From aa25ab45fcbf94921360a7da243dcfafc8b74074 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 4 Sep 2018 13:30:42 +0200 Subject: [PATCH] [mono-cil-strip] Add support for -q to be quiet. (#10421) --- man/mono-cil-strip.1 | 7 ++++++- mcs/tools/cil-strip/cilstrip.cs | 29 ++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/man/mono-cil-strip.1 b/man/mono-cil-strip.1 index 2a4ab8f1fd9..61885b26fb4 100644 --- a/man/mono-cil-strip.1 +++ b/man/mono-cil-strip.1 @@ -2,12 +2,17 @@ .SH NAME Mono CIL strip .SH SYNOPSIS -.B mono-cil-strip assembly [output-assembly] +.B mono-cil-strip [options] assembly [output-assembly] .SH DESCRIPTION mono-cil-strip is a tool which takes an assembly, and empty its method bodies. This is useful to reduce an assembly size when an assembly has already been compiled using Mono's Ahead Of Time compiler (AOT), where the CIL code is no longer necessary, but the metadata still is. +.SH OPTIONS +The following options are available: +.TP +.I "-q" +Only output errors. .SH COPYRIGHT Copyright (C) 2008 Novell, Inc (http://www.novell.com) .SH MAILING LISTS diff --git a/mcs/tools/cil-strip/cilstrip.cs b/mcs/tools/cil-strip/cilstrip.cs index ec80b178ca6..97cd4669eec 100644 --- a/mcs/tools/cil-strip/cilstrip.cs +++ b/mcs/tools/cil-strip/cilstrip.cs @@ -8,6 +8,7 @@ // using System; +using System.Collections.Generic; using System.Reflection; using Mono.Cecil; @@ -15,25 +16,32 @@ using Mono.Cecil; namespace Mono.CilStripper { class Program { - - static int Main (string [] args) + static bool quiet; + static int Main (string [] arguments) { + var args = new List (arguments); + if (args.Count > 0 && args [0] == "-q") { + quiet = true; + args.RemoveAt (0); + } Header (); - if (args.Length == 0) + if (args.Count == 0) Usage (); string file = args [0]; - string output = args.Length > 1 ? args [1] : file; + string output = args.Count > 1 ? args [1] : file; try { AssemblyDefinition assembly = AssemblyFactory.GetAssembly (file); StripAssembly (assembly, output); - if (file != output) - Console.WriteLine ("Assembly {0} stripped out into {1}", file, output); - else - Console.WriteLine ("Assembly {0} stripped", file); + if (!quiet) { + if (file != output) + Console.WriteLine ("Assembly {0} stripped out into {1}", file, output); + else + Console.WriteLine ("Assembly {0} stripped", file); + } return 0; } catch (TargetInvocationException tie) { Console.WriteLine ("Error: {0}", tie.InnerException); @@ -50,13 +58,16 @@ namespace Mono.CilStripper { static void Header () { + if (quiet) + return; Console.WriteLine ("Mono CIL Stripper"); Console.WriteLine (); } static void Usage () { - Console.WriteLine ("Usage: mono-cil-strip file [output]"); + Console.WriteLine ("Usage: mono-cil-strip [options] file [output]"); + Console.WriteLine (" -q Only output errors."); Environment.Exit (1); } } -- 2.11.4.GIT