Renamed ComConsts to SysMeta

- With the help of ChatGPT, some of the code is now properly commented
- Switched to calendar versioning due to the huge time skip and architectural changes
- Screenshot!
This commit is contained in:
Tony Bark 2023-01-06 22:00:48 -05:00
parent e44f7e8f95
commit 2634cc8de4
12 changed files with 86 additions and 51 deletions

View file

@ -1,8 +1,16 @@
# Change Log # 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)) - 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 - Replaced BasicApp with AboutApp
- Removd TerminalCancelEventArgs and everything related to it - Removd TerminalCancelEventArgs and everything related to it

View file

@ -1,5 +1,7 @@
# TOMAS # 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. 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 ## Requirements
@ -12,8 +14,6 @@ TOMAS (**To**ny's **Ma**naged Operating **S**ystem) is a hobby operating system
- VMWare Workstation Player - VMWare Workstation Player
- .NET 6 or later - .NET 6 or later
## License ## License
This project is licensed under the BSD 3-Clause license - see the [LICENSE](LICENSE) file for details. This project is licensed under the BSD 3-Clause license - see the [LICENSE](LICENSE) file for details.

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -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
{
/// <summary>
/// Name of the operating system
/// </summary>
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}";
/// <summary>
/// Generate the build number from the commit hash.
/// </summary>
static uint BuildFromCommit
{
get
{
var commit = Encoding.UTF8.GetBytes(ThisAssembly.Git.Commit);
return BitConverter.ToUInt32(commit, 0) % 1000000;
}
}
}

View file

@ -1 +1 @@
0.1 23.0

View file

@ -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;
/// <summary>
/// System metdata, such as name, version and build number.
/// </summary>
public struct SysMeta
{
/// <summary>
/// The name of the operating system.
/// </summary>
public const string NAME = "TOMAS";
/// <summary>
/// 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.
/// </summary>
public const string VERSION = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}";
/// <summary>
/// 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.
/// </summary>
[SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible")]
public static string BuildNumber = $"Build {BuildNumFromCommit}";
/// <summary>
/// Let's the system know that the file system is activated.
/// </summary>
public static bool IsFSActive = false;
/// <summary>
/// Generates the build number from the commit hash.
/// </summary>
/// <returns>The build number as a uint.</returns>
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;
}
}
}

View file

@ -1,4 +1,7 @@
global using Tomas.Common.Programs; global using Tomas.Common.Programs;
global using Tomas.Interface; global using Tomas.Interface;
global using Tomas.Kernel.Programs; 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; global using Os = Cosmos.System;

View file

@ -14,13 +14,6 @@ public class Kernel : Os.Kernel
protected override void Run() protected override void Run()
{ {
/*
Console.Write("$");
var input = Console.ReadLine();
Console.Write("Text typed: ");
Console.WriteLine(input);
*/
while (true) while (true)
{ {
var shell = new Shell(); var shell = new Shell();

View file

@ -1,6 +1,5 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using Tomas.Common;
namespace Tomas.Kernel.Programs; namespace Tomas.Kernel.Programs;
@ -8,7 +7,7 @@ public class About : IProgram
{ {
public bool Run(IShell shell) 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; var progs = shell.Programs;
foreach (var commands in progs.Keys) foreach (var commands in progs.Keys)
Console.WriteLine(commands); Console.WriteLine(commands);

View file

@ -5,8 +5,11 @@ namespace Tomas.Kernel;
public class Shell : IShell public class Shell : IShell
{ {
// The symbol to display before the cursor when the shell is waiting for user input
const char SYMBOL = '$'; 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<string, IProgram> Programs => new() public Dictionary<string, IProgram> Programs => new()
{ {
{"about", new About() }, {"about", new About() },
@ -15,13 +18,20 @@ public class Shell : IShell
{"commands", new Commands() } {"commands", new Commands() }
}; };
// A property that allows the shell to read a line of input from the user
public string ReadLine public string ReadLine
{ {
get get
{ {
// Write the SYMBOL character to the console
Console.Write(SYMBOL); Console.Write(SYMBOL);
// Read a line of input from the user
var readl = Console.ReadLine(); var readl = Console.ReadLine();
// Return the line of input
return readl; return readl;
} }
} }
} }

View file

@ -1,8 +1,5 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information. // 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; namespace Tomas.Kernel;
@ -21,7 +18,7 @@ class TomFS
Console.WriteLine("Creating system files."); Console.WriteLine("Creating system files.");
fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt"); fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine("Setting system preferences."); 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."); Console.WriteLine("File system loaded sucesfully.");
var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt"); var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine(intro); Console.WriteLine(intro);

View file

@ -8,7 +8,7 @@ public class About : IProgram
{ {
public bool Run(IShell shell) 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."); + "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework.");
return true; return true;
} }