Switched to BSD 3-Cluase license

- Use global usings in main kernal project
This commit is contained in:
Tony Bark 2023-01-06 19:03:07 -05:00
parent 7c16857c9a
commit 7b47f7afd8
17 changed files with 217 additions and 819 deletions

View file

@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
..\Changelog.md = ..\Changelog.md
..\LICENSE = ..\LICENSE
..\README.md = ..\README.md
TOMAS.sln.licenseheader = TOMAS.sln.licenseheader
EndProjectSection

View file

@ -1,4 +1,4 @@
extensions: designer.cs generated.cs
extensions: .cs .cpp .h .fs
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.

View file

@ -1,15 +1,15 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
namespace Tomas.Common
{
public struct ComConsts
{
/// <summary>
/// Name of the operating system
/// </summary>
public const string NAME = "TOMAS";
public struct ComConsts
{
/// <summary>
/// Name of the operating system
/// </summary>
public const string NAME = "TOMAS";
public static string Version = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}";
public static string VersionGit = $"{Version}-{ThisAssembly.Git.Commit}";
}
public static string Version = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}";
public static string VersionGit = $"{Version}-{ThisAssembly.Git.Commit}";
}
}

View file

@ -1,14 +1,16 @@
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
using Tomas.Interface;
namespace Tomas.Common.Programs
{
public class Clear : IProgram
{
public bool Run(IShell shell)
{
Console.Clear();
return true;
}
}
public class Clear : IProgram
{
public bool Run(IShell shell)
{
Console.Clear();
return true;
}
}
}

View file

@ -1,17 +1,19 @@
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
using Tomas.Interface;
namespace Tomas.Common.Programs
{
public class Commands : IProgram
{
public bool Run(IShell shell)
{
Console.WriteLine($"Commands:");
var progs = shell.Programs;
foreach (var commands in progs.Keys)
Console.WriteLine(commands);
return true;
}
}
public class Commands : IProgram
{
public bool Run(IShell shell)
{
Console.WriteLine($"Commands:");
var progs = shell.Programs;
foreach (var commands in progs.Keys)
Console.WriteLine(commands);
return true;
}
}
}

View file

@ -1,18 +1,17 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
using Tomas.Interface;
namespace Tomas.Common.Programs
{
public class FenSay : IProgram
{
public class FenSay : IProgram
{
/// <summary>
/// Fennec art by Todd Vargo
/// </summary>
const string _fennec = @" \/
/// <summary>
/// Fennec art by Todd Vargo
/// </summary>
const string _fennec = @" \/
/\ /\
//\\_//\\ ____
\_ _/ / /
@ -23,20 +22,20 @@ namespace Tomas.Common.Programs
[ [ / \/ _/
_[ [ \ /_/";
readonly string[] _phrases =
{
readonly string[] _phrases =
{
"[SCREAMS IN FENNEC]",
"Some people call me a coffee fox.",
"Drink Soda. It makes you see faster.",
"10/10, Wouldn't Recommend."
};
public bool Run(IShell shell)
{
var rng = new Random();
var phrases = _phrases[rng.Next(_phrases.Length)];
Console.WriteLine($"{phrases}{Environment.NewLine}{_fennec}");
return true;
}
}
public bool Run(IShell shell)
{
var rng = new Random();
var phrases = _phrases[rng.Next(_phrases.Length)];
Console.WriteLine($"{phrases}{Environment.NewLine}{_fennec}");
return true;
}
}
}

View file

@ -1,15 +1,15 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
namespace Tomas.Interface
{
public interface IProgram
{
/// <summary>
/// The program's main entry point. Boolean behaves as an exit point.
/// True and False are the equivalent to C's 0 and 1, i.e. "Success" and "Failure," respectfully.
/// </summary>
/// <param name="shell">Allows the program to interact with the shell.</param>
/// <returns>Exit back to shell.</returns>
bool Run(IShell shell);
}
public interface IProgram
{
/// <summary>
/// The program's main entry point. Boolean behaves as an exit point.
/// True and False are the equivalent to C's 0 and 1, i.e. "Success" and "Failure," respectfully.
/// </summary>
/// <param name="shell">Allows the program to interact with the shell.</param>
/// <returns>Exit back to shell.</returns>
bool Run(IShell shell);
}
}

View file

@ -1,14 +1,13 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace Tomas.Interface
{
public interface IShell
{
string ReadLine { get; }
public interface IShell
{
string ReadLine { get; }
Dictionary<string, IProgram> Programs { get; }
}
Dictionary<string, IProgram> Programs { get; }
}
}

View file

@ -0,0 +1,4 @@
global using Tomas.Common.Programs;
global using Tomas.Interface;
global using Tomas.Kernel.Programs;
global using Os = Cosmos.System;

View file

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
namespace Tomas.Kernal
{
public class Kernel : Sys.Kernel
public class Kernel : Os.Kernel
{
protected override void BeforeRun()
@ -15,7 +14,7 @@ namespace Tomas.Kernal
protected override void Run()
{
Console.Write("Input: ");
Console.Write("$");
var input = Console.ReadLine();
Console.Write("Text typed: ");
Console.WriteLine(input);

View file

@ -1,23 +1,21 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
using Tomas.Common;
using Tomas.Interface;
namespace Tomas.Kernel.Programs
{
public class About : IProgram
{
public bool Run(IShell shell)
{
Console.WriteLine($"{ComConsts.NAME} v{ComConsts.VersionGit}{Environment.NewLine}"
+ "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework.");
var progs = shell.Programs;
foreach (var commands in progs.Keys)
Console.WriteLine(commands);
{
public bool Run(IShell shell)
{
Console.WriteLine($"{ComConsts.NAME} v{ComConsts.VersionGit}{Environment.NewLine}"
+ "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework.");
var progs = shell.Programs;
foreach (var commands in progs.Keys)
Console.WriteLine(commands);
return true;
}
}
return true;
}
}
}

View file

@ -1,11 +1,7 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using Tomas.Common.Programs;
using Tomas.Interface;
using Tomas.Kernel.Programs;
using Sys = Cosmos.System;
namespace Tomas.Kernel
{

View file

@ -1,4 +1,4 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
@ -8,45 +8,45 @@ using Tomas.Common;
namespace Tomas.Kernel
{
class TomFS
{
public const string ROOT_DIR = "0:\\";
public static string SYSTEM_DIR = $"{ROOT_DIR}\\SYSTEM\\";
class TomFS
{
public const string ROOT_DIR = "0:\\";
public static string SYSTEM_DIR = $"{ROOT_DIR}\\SYSTEM\\";
public static void Initialize()
{
try
{
var fs = new CosmosVFS();
VFSManager.RegisterVFS(fs);
fs.CreateDirectory(SYSTEM_DIR);
Console.WriteLine("Creating system files.");
fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine("Setting system preferences.");
File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{ComConsts.NAME}, {ComConsts.VersionGit}");
Console.WriteLine("File system loaded sucesfully.");
var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine(intro);
public static void Initialize()
{
try
{
var fs = new CosmosVFS();
VFSManager.RegisterVFS(fs);
fs.CreateDirectory(SYSTEM_DIR);
Console.WriteLine("Creating system files.");
fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine("Setting system preferences.");
File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{ComConsts.NAME}, {ComConsts.VersionGit}");
Console.WriteLine("File system loaded sucesfully.");
var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine(intro);
}
catch
{
Console.WriteLine("File system failed to load! Not all functions will work.");
}
}
}
catch
{
Console.WriteLine("File system failed to load! Not all functions will work.");
}
}
public static string[] ListDirectories(string path)
{
try
{
var dirs = Directory.GetDirectories(path);
return dirs;
}
catch
{
Console.WriteLine("Failed to find any directories.");
throw;
}
}
}
public static string[] ListDirectories(string path)
{
try
{
var dirs = Directory.GetDirectories(path);
return dirs;
}
catch
{
Console.WriteLine("Failed to find any directories.");
throw;
}
}
}
}

View file

@ -1,42 +1,42 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
namespace Tomas.Terminal
{
class Program
class Program
{
static void Main()
{
while (true)
{
var shell = new Shell();
var command = shell.ReadLine;
var programs = shell.Programs;
if (!programs.TryGetValue(command, out var program))
{
static void Main()
{
while (true)
{
var shell = new Shell();
var command = shell.ReadLine;
var programs = shell.Programs;
if (!programs.TryGetValue(command, out var program))
{
Console.WriteLine("Command Not Found.");
continue;
}
try
{
var start = program.Run(shell);
switch (start)
{
case true:
continue;
case false:
Console.WriteLine("Program closed unexpectedly.");
continue;
}
}
catch (Exception err)
{
Console.WriteLine(err.Message);
}
}
}
Console.WriteLine("Command Not Found.");
continue;
}
try
{
var start = program.Run(shell);
switch (start)
{
case true:
continue;
case false:
Console.WriteLine("Program closed unexpectedly.");
continue;
}
}
catch (Exception err)
{
Console.WriteLine(err.Message);
}
}
}
}
}

View file

@ -1,4 +1,4 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
using Tomas.Common;
@ -6,13 +6,13 @@ using Tomas.Interface;
namespace Tomas.Terminal.Programs
{
public class About : IProgram
{
public bool Run(IShell shell)
{
Console.WriteLine($"{ComConsts.NAME} Terminal Emulator v{ComConsts.VersionGit}{Environment.NewLine}"
+ "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework.");
return true;
}
}
public class About : IProgram
{
public bool Run(IShell shell)
{
Console.WriteLine($"{ComConsts.NAME} Terminal Emulator v{ComConsts.VersionGit}{Environment.NewLine}"
+ "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework.");
return true;
}
}
}

View file

@ -1,4 +1,4 @@
// I license this project under the GPL 3.0 license.
// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
@ -8,11 +8,11 @@ using Tomas.Terminal.Programs;
namespace Tomas.Terminal
{
public class Shell : IShell
{
const char SYMBOL = '$';
public class Shell : IShell
{
const char SYMBOL = '$';
public Dictionary<string, IProgram> Programs => new Dictionary<string, IProgram>()
public Dictionary<string, IProgram> Programs => new Dictionary<string, IProgram>()
{
{"about", new About()},
{"fensay", new FenSay()},
@ -20,14 +20,14 @@ namespace Tomas.Terminal
{"commands", new Commands()}
};
public string ReadLine
{
get
{
Console.Write(SYMBOL);
var readl = Console.ReadLine();
return readl;
}
}
}
public string ReadLine
{
get
{
Console.Write(SYMBOL);
var readl = Console.ReadLine();
return readl;
}
}
}
}