[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / tools / monop / options.cs
blob92b6f7d2933e95b9723656b4b0f035fb373d4e87
1 //
2 // options.cs: Processes command line args
3 //
4 // Author:
5 // John Luke <john.luke@gmail.com>
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining
8 // a copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be
16 // included in all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 using System;
29 public class Options
31 public bool DeclaredOnly = false;
32 public bool FilterObsolete = false;
33 public bool PrintRefs = false;
34 public bool Search = false;
35 public bool ShowAll = false;
36 public bool ShowPrivate = false;
37 public string AssemblyReference = null;
38 public string Type = null;
39 public string PublicDir = null;
40 public string Style = null;
42 public Options ()
46 // returning true means processed ok
47 // and execution should continue
48 internal bool ProcessArgs (string[] args)
50 if (args.Length < 1) {
51 PrintHelp ();
52 return false;
55 for (int i = 0; i < args.Length; i++) {
56 switch (args[i]) {
57 case "-h":
58 case "--help":
59 PrintHelp ();
60 return false;
61 case "--runtime-version":
62 PrintRuntimeVersion ();
63 return false;
64 case "-d":
65 case "--declared-only":
66 DeclaredOnly = true;
67 break;
68 case "--filter-obsolete":
69 case "-f":
70 FilterObsolete = true;
71 break;
72 case "-p":
73 case "--private":
74 ShowPrivate = true;
75 break;
76 case "--refs":
77 PrintRefs = true;
78 break;
79 case "-xi":
80 PublicDir = "/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS";
81 Style = "xios";
82 break;
83 case "-xa":
84 PublicDir = "/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/2.1";
85 Style = "xand";
86 break;
87 case "-s":
88 case "-k":
89 case "--search":
90 Search = true;
91 break;
92 case "-c":
93 i++;
94 if (i < args.Length)
95 MonoP.Completion (args[i]);
96 return false;
97 case "-r":
98 i++;
99 if (i < args.Length)
100 AssemblyReference = args[i];
101 break;
102 case "-a":
103 ShowAll = true;
104 break;
105 default:
106 if (args[i].StartsWith ("-r:") || args[i].StartsWith ("/r:")) {
107 AssemblyReference = args [i].Substring (3);
108 break;
111 // The first unrecognizable option becomes
112 // the type to look up
113 if (Type == null) {
114 Type = args[i];
115 break;
118 // others are ignored
119 Console.WriteLine ("ignored: {0}", args[i]);
120 break;
124 // must specify at least one of these
125 if (Type == null && AssemblyReference == null)
126 return false;
128 return true;
131 void PrintRuntimeVersion ()
133 Console.WriteLine ("runtime version: {0}", Environment.Version);
136 void PrintHelp ()
138 Console.WriteLine ("Usage is: monop [option] [-c] [-r:Assembly] [class-name]");
139 Console.WriteLine ("");
140 Console.WriteLine ("options:");
141 Console.WriteLine ("\t--declared-only,-d\tOnly show members declared in the Type");
142 Console.WriteLine ("\t--help,-h\t\tShow this information");
143 Console.WriteLine ("\t--filter-obsolete,-f\tDo not show obsolete types and members");
144 Console.WriteLine ("\t--private,-p\t\tShow private members");
145 Console.WriteLine ("\t--refs\t\t\tPrint a list of the referenced assemblies for an assembly");
146 Console.WriteLine ("\t--runtime-version\tPrint runtime version");
147 Console.WriteLine ("\t--search,-s,-k\t\tSearch through all known namespaces");
148 Console.WriteLine ("\t--xi\t\tSet search style to Xamarin.iOS");
149 Console.WriteLine ("\t--xa\t\tSet search style to Xamarin.Android");
150 Console.WriteLine ("\t--a\t\tShows all the types declare in the specified assembly");