BadScript 2
Loading...
Searching...
No Matches
BadProgram.cs
Go to the documentation of this file.
16using BadScript2.IO;
18
23
27internal static class BadProgram
28{
32 private const string SETTINGS_FILE = "Settings.json";
33
34
38 private static BadRuntime LoadConsoleSettings(this BadRuntime runtime)
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
49 }
50
51
57 private static Task<int> Main(string[] args)
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)
76 .LoadConsoleSettings()
77 .UseCommonInterop()
78 .UseCompressionApi()
79 .UseFileSystemApi()
80 .UseHtmlApi()
81 .UseJsonApi()
82 .UseLinqApi()
83 .UseNetApi()
84 .UseNetHostApi()
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 }
101}
Exposes the BadScript Runtime Functionality to Consumers.
Definition BadRuntime.cs:28
BadRuntime UseLogMask(params BadLogMask[] mask)
Configures the Runtime to use the specified log masks.
BadRuntime UseConsoleLogWriter()
Configures the Runtime to use the default log writer implementation(log to console)
BadRuntime UseLocalModules(IFileSystem? fs=null)
Registers the Local Path Handler to the Module Importer.
BadRuntime LoadSettings(string settingsFile, IFileSystem? fileSystem=null)
Loads the specified settings file.
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.
Entrypoint for the Console Application.
Definition BadProgram.cs:28
const string SETTINGS_FILE
Defines the Settings file.
Definition BadProgram.cs:32
static BadRuntime LoadConsoleSettings(this BadRuntime runtime)
Loads the Settings.
Definition BadProgram.cs:38
static Task< int > Main(string[] args)
Entrypoint.
Definition BadProgram.cs:57
Static class that contains all the directories used by the console.
static string DataDirectory
The Data Directory.
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.
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.
Contains Logging system for the BadScript Runtime.
Definition BadLog.cs:6
Contains the 'html' console command implementation.
Contains the 'html' console command implementation.
Contains the 'run' console command implementation.
Contains the 'settings' console command implementation.
Contains the 'test' command implementation.
Contains the Core Functionality of the Console Application.
Contains the Entrypoint for the Console Application.
Definition BadProgram.cs:22
Contains IO Implementation for the BadScript2 Runtime.
Contains Common Interop Extensions and APIs for the BadScript2 Runtime.
Contains Compression Extensions and APIs for the BadScript2 Runtime.
Contains HTML Extensions and APIs for the BadScript2 Runtime.
Definition BadHtmlApi.cs:9
Contains IO Extensions and APIs for the BadScript2 Runtime.
Contains JSON Extensions and APIs for the BadScript2 Runtime.
Definition BadJson.cs:11
Contains Linq Extensions and APIs for the BadScript2 Runtime.
Contains Network Hosting Extensions and APIs for the BadScript2 Runtime.
Contains Networking Extensions and APIs for the BadScript2 Runtime.
Definition BadNetApi.cs:6
Contains the Settings Implementation.