mirror of
https://github.com/tonytins/tomas.git
synced 2025-03-22 15:42:18 +00:00
Return of kernal programs
- Boot log is now cleared - File scoped namespaces work
This commit is contained in:
parent
7530f8500b
commit
a06f9ccc9f
9 changed files with 136 additions and 94 deletions
|
@ -19,7 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Interface", "Tomas.In
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Terminal", "Tomas.Terminal\Tomas.Terminal.csproj", "{49E67E55-F9D2-419A-8097-38F39E98A95E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Kernal", "Tomas.Kernal\Tomas.Kernal.csproj", "{20750C95-A3C7-4958-BA9F-56E4C3BD0293}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Kernel", "Tomas.Kernal\Tomas.Kernel.csproj", "{20750C95-A3C7-4958-BA9F-56E4C3BD0293}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
global using Tomas.Common.Programs;
|
||||
global using Tomas.Interface;
|
||||
global using Tomas.Kernel;
|
||||
global using Tomas.Kernel.Programs;
|
||||
global using Os = Cosmos.System;
|
|
@ -2,22 +2,54 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
using System;
|
||||
|
||||
namespace Tomas.Kernal
|
||||
namespace Tomas.Kernel;
|
||||
|
||||
public class Kernel : Os.Kernel
|
||||
{
|
||||
public class Kernel : Os.Kernel
|
||||
{
|
||||
|
||||
protected override void BeforeRun()
|
||||
{
|
||||
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
|
||||
Console.Clear();
|
||||
Console.WriteLine("TOMAS booted successfully.");
|
||||
}
|
||||
|
||||
protected override void Run()
|
||||
{
|
||||
/*
|
||||
Console.Write("$");
|
||||
var input = Console.ReadLine();
|
||||
Console.Write("Text typed: ");
|
||||
Console.WriteLine(input);
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
using System;
|
||||
using Tomas.Common;
|
||||
|
||||
namespace Tomas.Kernel.Programs
|
||||
namespace Tomas.Kernel.Programs;
|
||||
|
||||
public class About : IProgram
|
||||
{
|
||||
public class About : IProgram
|
||||
{
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
Console.WriteLine($"{ComConsts.NAME} v{ComConsts.VersionGit}{Environment.NewLine}"
|
||||
|
@ -17,5 +17,4 @@ namespace Tomas.Kernel.Programs
|
|||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
13
src/Tomas.Kernal/Programs/Shutdown.cs
Normal file
13
src/Tomas.Kernal/Programs/Shutdown.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace Tomas.Kernel.Programs;
|
||||
|
||||
internal class Shutdown : IProgram
|
||||
{
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
Environment.Exit(Environment.ExitCode);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -3,18 +3,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Tomas.Kernel
|
||||
namespace Tomas.Kernel;
|
||||
|
||||
public class Shell : IShell
|
||||
{
|
||||
public class Shell : IShell
|
||||
{
|
||||
const char SYMBOL = '$';
|
||||
|
||||
public Dictionary<string, IProgram> Programs => new Dictionary<string, IProgram>()
|
||||
{
|
||||
{"about", new About()},
|
||||
{"fensay", new FenSay()},
|
||||
{"clear", new Clear()},
|
||||
{"commands", new Commands()}
|
||||
{"about", new About() },
|
||||
{"fensay", new FenSay() },
|
||||
{"clear", new Clear() },
|
||||
{"commands", new Commands() },
|
||||
{"shutdown", new Shutdown() }
|
||||
};
|
||||
|
||||
public string ReadLine
|
||||
|
@ -26,5 +27,4 @@ namespace Tomas.Kernel
|
|||
return readl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ using Cosmos.System.FileSystem;
|
|||
using Cosmos.System.FileSystem.VFS;
|
||||
using Tomas.Common;
|
||||
|
||||
namespace Tomas.Kernel
|
||||
namespace Tomas.Kernel;
|
||||
|
||||
class TomFS
|
||||
{
|
||||
class TomFS
|
||||
{
|
||||
public const string ROOT_DIR = "0:\\";
|
||||
public static string SYSTEM_DIR = $"{ROOT_DIR}\\SYSTEM\\";
|
||||
|
||||
|
@ -48,5 +48,4 @@ namespace Tomas.Kernel
|
|||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
// I license this project under the BSD 3-Clause license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
using Tomas.Common;
|
||||
using Tomas.Interface;
|
||||
|
||||
namespace Tomas.Terminal.Programs
|
||||
namespace Tomas.Terminal.Programs;
|
||||
|
||||
public class About : IProgram
|
||||
{
|
||||
public class About : IProgram
|
||||
{
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
Console.WriteLine($"{ComConsts.NAME} Terminal Emulator v{ComConsts.VersionGit}{Environment.NewLine}"
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue