BadScript 2
Loading...
Searching...
No Matches
BadScript2.Console.BadProgram Class Reference

Entrypoint for the Console Application. More...

Static Private Member Functions

static BadRuntime LoadConsoleSettings (this BadRuntime runtime)
 Loads the Settings.
 
static Task< int > Main (string[] args)
 Entrypoint.
 

Static Private Attributes

const string SETTINGS_FILE = "Settings.json"
 Defines the Settings file.
 

Detailed Description

Entrypoint for the Console Application.

Definition at line 27 of file BadProgram.cs.

Member Function Documentation

◆ LoadConsoleSettings()

static BadRuntime BadScript2.Console.BadProgram.LoadConsoleSettings ( this BadRuntime  runtime)
staticprivate

Loads the Settings.

Definition at line 38 of file BadProgram.cs.

39 {
40 BadSettings consoleSettings = new BadSettings(string.Empty);
42 rootDir = rootDir.Remove(rootDir.Length - 1, 1);
43
44 consoleSettings.SetProperty("RootDirectory", new BadSettings(rootDir, string.Empty));
45 consoleSettings.SetProperty("DataDirectory", new BadSettings(BadConsoleDirectories.DataDirectory, string.Empty));
46 BadSettingsProvider.RootSettings.SetProperty("Console", consoleSettings);
47
48 return runtime.LoadSettings(Path.Combine(BadFileSystem.Instance.GetStartupDirectory(), SETTINGS_FILE));
49 }
const string SETTINGS_FILE
Defines the Settings file.
Definition BadProgram.cs:32
Static class that contains all the directories used by the console.
static string DataDirectory
The Data Directory.
Public interface for the filesystem abstraction of the BadScript Engine.
static IFileSystem Instance
File System implementation.
Public Api for the Settings System.
void SetProperty(string propertyName, BadSettings value, bool invokeOnChange=true)
Sets the Property with the given Name.
Helper class that can be used to automatically load a settings object from a file.
static BadSettings RootSettings
Returns the Root Settings Object.
string GetStartupDirectory()
The Startup Directory of the Application.

◆ Main()

static Task< int > BadScript2.Console.BadProgram.Main ( string[]  args)
staticprivate

Entrypoint.

Parameters
argsCommandline Arguments
Returns
Return Code

Definition at line 57 of file BadProgram.cs.

58 {
60
61 if (args.Contains("--logmask"))
62 {
63 int idx = Array.IndexOf(args, "--logmask");
64
65 if (idx + 1 < args.Length)
66 {
67 string maskStr = args[idx + 1];
68 mask = BadLogMask.GetMask(maskStr.Split(';').Select(x => (BadLogMask)x).ToArray());
69 args = args.Where((_, i) => i != idx && i != idx + 1).ToArray();
70 }
71 }
72
73 using BadRuntime runtime = new BadRuntime()
74 .UseLogMask(mask)
75 .UseConsoleLogWriter()
76 .LoadConsoleSettings()
77 .UseCommonInterop()
78 .UseCompressionApi()
79 .UseFileSystemApi()
80 .UseHtmlApi()
81 .UseJsonApi()
82 .UseLinqApi()
83 .UseNetApi()
84 .UseNetHostApi()
85 .UseLocalModules();
86
87
89 new BadDefaultRunSystem(runtime),
90 new BadTestSystem(runtime),
91 new BadRunSystem(runtime),
92 new BadSettingsSystem(runtime),
93 new BadHtmlSystem(runtime),
94 new BadRemoteConsoleSystem(runtime),
95 new BadDocsSystem(runtime)
96 );
97
98
99 return runner.Run(args);
100 }
Implements a Mask for Log Messages.
Definition BadLogMask.cs:7
static readonly BadLogMask None
Static Helper for the "None" Mask.
Definition BadLogMask.cs:24
static BadLogMask GetMask(params BadLogMask[] masks)
Returns a combined mask of all masks provided.
Class that can register console systems and run them.
Task< int > Run(string[] args)
Runs a system with the specified arguments.
Default Run System Is used to enable running scripts by simply typing "bs my/path/to/script....
Runs one or more BadScript scripts.

Member Data Documentation

◆ SETTINGS_FILE

const string BadScript2.Console.BadProgram.SETTINGS_FILE = "Settings.json"
staticprivate

Defines the Settings file.

Definition at line 32 of file BadProgram.cs.


The documentation for this class was generated from the following file: