diff --git a/Changelog.md b/Changelog.md index dc0f161..de70050 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,8 +1,16 @@ # Change Log -## 0.1.0 +## v23.0 + +- Calendar versioning, `YY.MINOR.MICRO` + +- Build number based on commit hash + +Due to the huge time skip and architectural changes, I've (retroactively) switched to calendar versioning with ``v0.1`` now known as ``v20.1`` as well. + +## v20.1 - Filesystem (based on the Cosmos Wiki [guide](https://csos-guide-to-cosmos.fandom.com/wiki/Getting_Started_-_Materials_and_Setting_Up)) -- Proper versioning (thanks to Gitinfo!) +- Semantic versioning - Replaced BasicApp with AboutApp - Removd TerminalCancelEventArgs and everything related to it \ No newline at end of file diff --git a/README.md b/README.md index 4a212b9..d986d72 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # TOMAS +![](C:\Users\zc456\source\repos\tomas\screenshot.png) + TOMAS (**To**ny's **Ma**naged Operating **S**ystem) is a hobby operating system based on the [COSMOS](https://github.com/CosmosOS/Cosmos) framework that comes with a respective terminal emulator. ## Requirements @@ -7,13 +9,11 @@ TOMAS (**To**ny's **Ma**naged Operating **S**ystem) is a hobby operating system ### Prerequisites - Operating System - - Visual Studio 2022 - - COSMOS User Kit v2022 or later - - VMWare Workstation Player + - Visual Studio 2022 + - COSMOS User Kit v2022 or later + - VMWare Workstation Player - .NET 6 or later - - ## License This project is licensed under the BSD 3-Clause license - see the [LICENSE](LICENSE) file for details. diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..40fc579 Binary files /dev/null and b/screenshot.png differ diff --git a/src/Tomas.Common/ComConsts.cs b/src/Tomas.Common/ComConsts.cs deleted file mode 100644 index f9bdd81..0000000 --- a/src/Tomas.Common/ComConsts.cs +++ /dev/null @@ -1,29 +0,0 @@ -// I license this project under the BSD 3-Clause license. -// See the LICENSE file in the project root for more information. -using System.Text; - -namespace Tomas.Common; - -public struct ComConsts -{ - /// - /// Name of the operating system - /// - public const string NAME = "TOMAS"; - public const string VERSION = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}"; - - [SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible")] - public static string BuildNumber = $"Build {BuildFromCommit}"; - - /// - /// Generate the build number from the commit hash. - /// - static uint BuildFromCommit - { - get - { - var commit = Encoding.UTF8.GetBytes(ThisAssembly.Git.Commit); - return BitConverter.ToUInt32(commit, 0) % 1000000; - } - } -} \ No newline at end of file diff --git a/src/Tomas.Common/GitInfo.txt b/src/Tomas.Common/GitInfo.txt index ceab6e1..4266d86 100644 --- a/src/Tomas.Common/GitInfo.txt +++ b/src/Tomas.Common/GitInfo.txt @@ -1 +1 @@ -0.1 \ No newline at end of file +23.0 \ No newline at end of file diff --git a/src/Tomas.Common/SysMeta.cs b/src/Tomas.Common/SysMeta.cs new file mode 100644 index 0000000..c9f1c90 --- /dev/null +++ b/src/Tomas.Common/SysMeta.cs @@ -0,0 +1,54 @@ +// I license this project under the BSD 3-Clause license. +// See the LICENSE file in the project root for more information. +using System.Text; + +namespace Tomas.Common; + +/// +/// System metdata, such as name, version and build number. +/// +public struct SysMeta +{ + /// + /// The name of the operating system. + /// + public const string NAME = "TOMAS"; + + /// + /// The version of the operating system, in the Calendar Versioning format: "yy.minor.patch". + /// The year, minor, and patch version numbers are automatically extracted from the Git repository + /// using the ThisAssembly.Git.SemVer object. + /// + public const string VERSION = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}"; + + /// + /// The build number of the operating system, generated from the commit hash. + /// The build number is a 6-digit number, with the first 3 digits being the first 3 digits of the commit hash + /// converted to a uint, and the last 3 digits being the last 3 digits of the commit hash converted to a uint. + /// + [SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible")] + public static string BuildNumber = $"Build {BuildNumFromCommit}"; + + /// + /// Let's the system know that the file system is activated. + /// + public static bool IsFSActive = false; + + /// + /// Generates the build number from the commit hash. + /// + /// The build number as a uint. + static uint BuildNumFromCommit + { + get + { + // Get the bytes of the commit hash as a UTF-8 encoded string + var commit = Encoding.UTF8.GetBytes(ThisAssembly.Git.Commit); + + // Convert the first 4 bytes of the commit hash to a uint and return it modulo 1000000 + // (this will give us a 6-digit number with the first 3 digits being the first 3 digits of the commit hash + // and the last 3 digits being the last 3 digits of the commit hash) + return BitConverter.ToUInt32(commit, 0) % 1000000; + } + } +} diff --git a/src/Tomas.Kernal/GlobalUsing.cs b/src/Tomas.Kernal/GlobalUsing.cs index 9d9efd3..b847d34 100644 --- a/src/Tomas.Kernal/GlobalUsing.cs +++ b/src/Tomas.Kernal/GlobalUsing.cs @@ -1,4 +1,7 @@ global using Tomas.Common.Programs; global using Tomas.Interface; global using Tomas.Kernel.Programs; +global using Cosmos.System.FileSystem; +global using Cosmos.System.FileSystem.VFS; +global using Tomas.Common; global using Os = Cosmos.System; \ No newline at end of file diff --git a/src/Tomas.Kernal/Kernel.cs b/src/Tomas.Kernal/Kernel.cs index 1bffafd..3705c9c 100644 --- a/src/Tomas.Kernal/Kernel.cs +++ b/src/Tomas.Kernal/Kernel.cs @@ -14,13 +14,6 @@ public class Kernel : Os.Kernel protected override void Run() { - /* - Console.Write("$"); - var input = Console.ReadLine(); - Console.Write("Text typed: "); - Console.WriteLine(input); - */ - while (true) { var shell = new Shell(); diff --git a/src/Tomas.Kernal/Programs/About.cs b/src/Tomas.Kernal/Programs/About.cs index 1814a0c..365c563 100644 --- a/src/Tomas.Kernal/Programs/About.cs +++ b/src/Tomas.Kernal/Programs/About.cs @@ -1,6 +1,5 @@ // I license this project under the BSD 3-Clause license. // See the LICENSE file in the project root for more information. -using Tomas.Common; namespace Tomas.Kernel.Programs; @@ -8,7 +7,7 @@ public class About : IProgram { public bool Run(IShell shell) { - Console.WriteLine($"TOMAS v{ComConsts.VERSION} ({ComConsts.BuildNumber}) is a hobby operating system written in C# using the COSMOS framework.{Environment.NewLine}Commands:"); + Console.WriteLine($"TOMAS v{SysMeta.VERSION} ({SysMeta.BuildNumber}) is a hobby operating system written in C# using the COSMOS framework.{Environment.NewLine}Commands:"); var progs = shell.Programs; foreach (var commands in progs.Keys) Console.WriteLine(commands); diff --git a/src/Tomas.Kernal/Shell.cs b/src/Tomas.Kernal/Shell.cs index 975324c..1b49aa5 100644 --- a/src/Tomas.Kernal/Shell.cs +++ b/src/Tomas.Kernal/Shell.cs @@ -5,8 +5,11 @@ namespace Tomas.Kernel; public class Shell : IShell { + // The symbol to display before the cursor when the shell is waiting for user input const char SYMBOL = '$'; + // A dictionary containing the programs available to the shell, with the keys being the program names + // and the values being the program objects public Dictionary Programs => new() { {"about", new About() }, @@ -15,13 +18,20 @@ public class Shell : IShell {"commands", new Commands() } }; + // A property that allows the shell to read a line of input from the user public string ReadLine { get { + // Write the SYMBOL character to the console Console.Write(SYMBOL); + + // Read a line of input from the user var readl = Console.ReadLine(); + + // Return the line of input return readl; } } } + diff --git a/src/Tomas.Kernal/TomFS.cs b/src/Tomas.Kernal/TomFS.cs index 0854c4e..eca77af 100644 --- a/src/Tomas.Kernal/TomFS.cs +++ b/src/Tomas.Kernal/TomFS.cs @@ -1,8 +1,5 @@ // I license this project under the BSD 3-Clause license. // See the LICENSE file in the project root for more information. -using Cosmos.System.FileSystem; -using Cosmos.System.FileSystem.VFS; -using Tomas.Common; namespace Tomas.Kernel; @@ -21,7 +18,7 @@ class TomFS 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.BuildNumber}"); + File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{SysMeta.NAME} v{SysMeta.VERSION} ({SysMeta.BuildNumber})"); Console.WriteLine("File system loaded sucesfully."); var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt"); Console.WriteLine(intro); diff --git a/src/Tomas.Terminal/Programs/About.cs b/src/Tomas.Terminal/Programs/About.cs index e5ddf6c..bf3e15f 100644 --- a/src/Tomas.Terminal/Programs/About.cs +++ b/src/Tomas.Terminal/Programs/About.cs @@ -8,7 +8,7 @@ public class About : IProgram { public bool Run(IShell shell) { -Console.WriteLine($"{ComConsts.NAME} Terminal Emulator v{ComConsts.BuildNumber}{Environment.NewLine}" +Console.WriteLine($"{SysMeta.NAME} Terminal Emulator v{SysMeta.BuildNumber}{Environment.NewLine}" + "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework."); return true; }