1 //
2 // Copyright (c) 2010-2024 Antmicro
3 // Copyright (c) 2011-2015 Realtime Embedded
4 //
5 // This file is licensed under the MIT License.
6 // Full license text is available in 'licenses/MIT.txt'.
7 //
8 using Antmicro.OptionsParser;
9 
10 namespace Antmicro.Renode.UI
11 {
12     public class Options : IValidatedOptions
13     {
14         [Name('p', "plain"), DefaultValue(false), Description("Remove steering codes (e.g., colours) from output.")]
15         public bool Plain { get; set; }
16 
17         [Name('P', "port"), DefaultValue(-1), Description("Instead of opening a window, listen for Monitor commands on the specified port.")]
18         public int Port { get; set; }
19 
20         [Name('e', "execute"), Description("Execute command on startup (executed after the optional script). May be used many times.")]
21         public string[] Execute { get; set; }
22 
23         [Name("config"), Description("Use the configuration file from the provided path, or create one if it does not exist")]
24         public string ConfigFile { get; set; }
25 
26         [Name("disable-xwt"), Alias("disable-gui"), DefaultValue(false), Description("Disable XWT GUI support. It automatically sets HideMonitor.")]
27         public bool DisableXwt { get; set; }
28 
29         [Name("file-to-include / snapshot"), PositionalArgument(0)]
30         public string FilePath { get; set; }
31 
32         [Name("hide-monitor"), DefaultValue(false), Description("Do not show the Monitor window.")]
33         public bool HideMonitor { get; set; }
34 
35         [Name("hide-log"), DefaultValue(false), Description("Do not show log messages in a console.")]
36         public bool HideLog { get; set; }
37 
38         [Name("hide-analyzers"), DefaultValue(false), Description("Do not show analyzers.")]
39         public bool HideAnalyzers { get; set; }
40 
41         [Name("pid-file"), Description("Write PID of the Renode instance to the provided file.")]
42         public string PidFile { get; set; }
43 
44         [Name("robot-server-port"), DefaultValue(-1), Description("Start robot framework remote server on the specified port.")]
45         public int RobotFrameworkRemoteServerPort { get; set; }
46         [Name("robot-debug-on-error"), DefaultValue(false), Description("Initialize GUI for Robot tests debugging")]
47         public bool RobotDebug { get; set; }
48 
49         [Name('v', "version"), DefaultValue(false), Description("Print version and exit.")]
50         public bool Version { get; set; }
51 
52         [Name("console"), Description("Run the Monitor in the console instead of a separate window")]
53         public bool Console { get; set; }
54 
55         [Name("keep-temporary-files"), Description("Don't clean temporary files on exit")]
56         public bool KeepTemporaryFiles { get; set; }
57 
Validate(out string error)58         public bool Validate(out string error)
59         {
60             if(HideMonitor && Console)
61             {
62                 error = "--hide-monitor and --console cannot be set at the same time";
63                 return false;
64             }
65 
66             if(DisableXwt)
67             {
68                 HideMonitor = true;
69             }
70 
71             error = null;
72             return true;
73         }
74     }
75 }
76 
77