diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
new file mode 100644
index 0000000..60d9642
--- /dev/null
+++ b/.github/workflows/dotnet.yml
@@ -0,0 +1,28 @@
+name: .NET
+
+on:
+ schedule:
+ - cron: "0 0 * * 0"
+ push:
+ branches: [master, main, develop, "feature/**"]
+ pull_request:
+ branches: [master, main, develop, "feature/**"]
+
+jobs:
+ build:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ dotnet: ["3.1.x", "5.0.x"]
+ os: [windows-latest, ubuntu-latest, macOS-latest]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: ${{ matrix.dotnet }}
+ - name: Install dependencies
+ run: dotnet restore src/Tomas.Terminal
+ - name: Build
+ run: dotnet build src/Tomas.Terminal -c Release --no-restore
diff --git a/README.md b/README.md
index 7c16a7c..7d4f3f5 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ TOMAS (**To**ny's **Ma**naged Operating **S**ystem) is a operating system based
- Visual Studio 2019
- COSMOS User Kit v20190508 or later
- VMWare Workstation Player
-- .NET Core 2.1 or later
+- .NET Core 3.1 or later
diff --git a/src/Tomas.Common/Programs/Clear.cs b/src/Tomas.Common/Programs/Clear.cs
index f9dcbcc..835d4ce 100644
--- a/src/Tomas.Common/Programs/Clear.cs
+++ b/src/Tomas.Common/Programs/Clear.cs
@@ -1,11 +1,11 @@
using System;
-using Tomas.Interface.Shell;
+using Tomas.Interface;
-namespace Tomas.Kernel.Programs
+namespace Tomas.Common.Programs
{
public class Clear : IProgram
{
- public bool Start()
+ public bool Run(IShell shell)
{
Console.Clear();
return true;
diff --git a/src/Tomas.Common/Programs/Commands.cs b/src/Tomas.Common/Programs/Commands.cs
new file mode 100644
index 0000000..48469de
--- /dev/null
+++ b/src/Tomas.Common/Programs/Commands.cs
@@ -0,0 +1,17 @@
+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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Tomas.Common/Programs/FenSay.cs b/src/Tomas.Common/Programs/FenSay.cs
index 26b8fcf..891f4a3 100644
--- a/src/Tomas.Common/Programs/FenSay.cs
+++ b/src/Tomas.Common/Programs/FenSay.cs
@@ -1,9 +1,10 @@
// I license this project under the GPL 3.0 license.
// See the LICENSE file in the project root for more information.
-using System;
-using Tomas.Interface.Shell;
-namespace Tomas.Kernel.Programs
+using System;
+using Tomas.Interface;
+
+namespace Tomas.Common.Programs
{
public class FenSay : IProgram
{
@@ -11,7 +12,7 @@ namespace Tomas.Kernel.Programs
///
/// Fennec art by Todd Vargo
///
- const string FENNEC = @" \/
+ const string _fennec = @" \/
/\ /\
//\\_//\\ ____
\_ _/ / /
@@ -22,19 +23,19 @@ namespace Tomas.Kernel.Programs
[ [ / \/ _/
_[ [ \ /_/";
- readonly string[] _fenPhrases =
+ readonly string[] _phrases =
{
- "[Screams in Fennec]",
+ "[SCREAMS IN FENNEC]",
"Some people call me a coffee fox.",
"Drink Soda. It makes you see faster.",
"10/10, Wouldn't Recommend."
};
- public bool Start()
+ public bool Run(IShell shell)
{
var rng = new Random();
- var phrases = _fenPhrases[rng.Next(_fenPhrases.Length)];
- Console.WriteLine($"{phrases}{Environment.NewLine}{FENNEC}");
+ var phrases = _phrases[rng.Next(_phrases.Length)];
+ Console.WriteLine($"{phrases}{Environment.NewLine}{_fennec}");
return true;
}
}
diff --git a/src/Tomas.Interface/IProgram.cs b/src/Tomas.Interface/IProgram.cs
new file mode 100644
index 0000000..a6dc8c9
--- /dev/null
+++ b/src/Tomas.Interface/IProgram.cs
@@ -0,0 +1,15 @@
+// I license this project under the GPL 3.0 license.
+// See the LICENSE file in the project root for more information.
+namespace Tomas.Interface
+{
+ public interface IProgram
+ {
+ ///
+ /// 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.
+ ///
+ /// Allows the program to interact with the shell.
+ /// Exit back to shell.
+ bool Run(IShell shell);
+ }
+}
\ No newline at end of file
diff --git a/src/Tomas.Interface/Shell/IShell.cs b/src/Tomas.Interface/IShell.cs
similarity index 62%
rename from src/Tomas.Interface/Shell/IShell.cs
rename to src/Tomas.Interface/IShell.cs
index 524ebc9..20b4fe5 100644
--- a/src/Tomas.Interface/Shell/IShell.cs
+++ b/src/Tomas.Interface/IShell.cs
@@ -1,9 +1,14 @@
// I license this project under the GPL 3.0 license.
// See the LICENSE file in the project root for more information.
-namespace Tomas.Interface.Shell
+
+using System.Collections.Generic;
+
+namespace Tomas.Interface
{
public interface IShell
{
string ReadLine { get; }
+
+ Dictionary Programs { get; }
}
}
\ No newline at end of file
diff --git a/src/Tomas.Interface/Shell/IProgram.cs b/src/Tomas.Interface/Shell/IProgram.cs
deleted file mode 100644
index 9fc64aa..0000000
--- a/src/Tomas.Interface/Shell/IProgram.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-// I license this project under the GPL 3.0 license.
-// See the LICENSE file in the project root for more information.
-namespace Tomas.Interface.Shell
-{
- public interface IProgram
- {
- bool Start();
- }
-}
\ No newline at end of file
diff --git a/src/Tomas.Kernel/Kernel.cs b/src/Tomas.Kernel/Kernel.cs
index cdebb47..3d24d30 100644
--- a/src/Tomas.Kernel/Kernel.cs
+++ b/src/Tomas.Kernel/Kernel.cs
@@ -3,9 +3,6 @@
using System;
using System.Collections.Generic;
using Tomas.Common;
-using Tomas.Interface.Shell;
-using Tomas.Kernel.Programs;
-using Tomas.Terminal.Programs;
using Sys = Cosmos.System;
namespace Tomas.Kernel
@@ -42,10 +39,22 @@ namespace Tomas.Kernel
continue;
}
- var start = program.Start();
- if (start) continue;
-
- break;
+ 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);
+ }
}
}
diff --git a/src/Tomas.Kernel/OSConsts.cs b/src/Tomas.Kernel/OSConsts.cs
deleted file mode 100644
index 3961de3..0000000
--- a/src/Tomas.Kernel/OSConsts.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// I license this project under the GPL 3.0 license.
-// See the LICENSE file in the project root for more information.
-using System.Collections.Generic;
-using Tomas.Interface.Shell;
-using Tomas.Kernel.Programs;
-using Tomas.Terminal.Programs;
-
-namespace Tomas.Kernel
-{
- public struct OSConsts
- {
- public static Dictionary Programs => new Dictionary()
- {
- {"about", new About()},
- {"fensay", new FenSay()},
- {"clear", new Clear()}
- };
- }
-}
diff --git a/src/Tomas.Kernel/Programs/About.cs b/src/Tomas.Kernel/Programs/About.cs
index b6a60ae..9ce8ad4 100644
--- a/src/Tomas.Kernel/Programs/About.cs
+++ b/src/Tomas.Kernel/Programs/About.cs
@@ -1,19 +1,19 @@
// I license this project under the GPL 3.0 license.
// See the LICENSE file in the project root for more information.
+
using System;
using Tomas.Common;
-using Tomas.Interface.Shell;
-using Tomas.Kernel;
+using Tomas.Interface;
-namespace Tomas.Terminal.Programs
+namespace Tomas.Kernel.Programs
{
public class About : IProgram
{
- public bool Start()
+ public bool Run(IShell shell)
{
- Console.WriteLine($"{ComConsts.NAME} v{ComConsts.VersionGit}");
-
- var progs = OSConsts.Programs;
+ 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);
diff --git a/src/Tomas.Kernel/Shell.cs b/src/Tomas.Kernel/Shell.cs
index d443055..64207a5 100644
--- a/src/Tomas.Kernel/Shell.cs
+++ b/src/Tomas.Kernel/Shell.cs
@@ -1,8 +1,9 @@
// I license this project under the GPL 3.0 license.
// See the LICENSE file in the project root for more information.
using System;
-using Tomas.Common;
-using Tomas.Interface.Shell;
+using System.Collections.Generic;
+using Tomas.Common.Programs;
+using Tomas.Interface;
using Tomas.Kernel.Programs;
using Sys = Cosmos.System;
@@ -12,6 +13,14 @@ namespace Tomas.Kernel
{
const char SYMBOL = '$';
+ public Dictionary Programs => new Dictionary()
+ {
+ {"about", new About()},
+ {"fensay", new FenSay()},
+ {"clear", new Clear()},
+ {"commands", new Commands()}
+ };
+
public string ReadLine
{
get
diff --git a/src/Tomas.Terminal/Program.cs b/src/Tomas.Terminal/Program.cs
index d9e50a1..5b514fb 100644
--- a/src/Tomas.Terminal/Program.cs
+++ b/src/Tomas.Terminal/Program.cs
@@ -12,17 +12,30 @@ namespace Tomas.Terminal
{
var shell = new Shell();
var command = shell.ReadLine;
+ var programs = shell.Programs;
- if (!TermConsts.Programs.TryGetValue(command, out var program))
+ if (!programs.TryGetValue(command, out var program))
{
- Console.WriteLine("Command Unknown.");
+ Console.WriteLine("Command Not Found.");
continue;
}
- var start = program.Start();
- if (start) continue;
-
- break;
+ 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);
+ }
}
}
}
diff --git a/src/Tomas.Terminal/Programs/About.cs b/src/Tomas.Terminal/Programs/About.cs
index 3354cc3..d33706a 100644
--- a/src/Tomas.Terminal/Programs/About.cs
+++ b/src/Tomas.Terminal/Programs/About.cs
@@ -2,21 +2,16 @@
// See the LICENSE file in the project root for more information.
using System;
using Tomas.Common;
-using Tomas.Interface.Shell;
+using Tomas.Interface;
namespace Tomas.Terminal.Programs
{
public class About : IProgram
{
- public bool Start()
+ public bool Run(IShell shell)
{
- Console.WriteLine($"{ComConsts.NAME} v{ComConsts.VersionGit}{Environment.NewLine}");
-
- Console.WriteLine("Commands:");
- var progs = TermConsts.Programs;
- foreach (var commands in progs.Keys)
- Console.WriteLine(commands);
-
+ 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;
}
}
diff --git a/src/Tomas.Terminal/Shell.cs b/src/Tomas.Terminal/Shell.cs
index b8d9c82..20b83bd 100644
--- a/src/Tomas.Terminal/Shell.cs
+++ b/src/Tomas.Terminal/Shell.cs
@@ -1,7 +1,10 @@
// I license this project under the GPL 3.0 license.
// See the LICENSE file in the project root for more information.
using System;
-using Tomas.Interface.Shell;
+using System.Collections.Generic;
+using Tomas.Common.Programs;
+using Tomas.Interface;
+using Tomas.Terminal.Programs;
namespace Tomas.Terminal
{
@@ -9,6 +12,14 @@ namespace Tomas.Terminal
{
const char SYMBOL = '$';
+ public Dictionary Programs => new Dictionary()
+ {
+ {"about", new About()},
+ {"fensay", new FenSay()},
+ {"clear", new Clear()},
+ {"commands", new Commands()}
+ };
+
public string ReadLine
{
get
diff --git a/src/Tomas.Terminal/TermConsts.cs b/src/Tomas.Terminal/TermConsts.cs
deleted file mode 100644
index 4f63614..0000000
--- a/src/Tomas.Terminal/TermConsts.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// I license this project under the GPL 3.0 license.
-// See the LICENSE file in the project root for more information.
-using System.Collections.Generic;
-using Tomas.Interface.Shell;
-using Tomas.Kernel.Programs;
-using Tomas.Terminal.Programs;
-
-namespace Tomas.Terminal
-{
- public struct TermConsts
- {
- public static Dictionary Programs => new Dictionary()
- {
- {"about", new About()},
- {"fensay", new FenSay()},
- {"clear", new Clear()}
- };
- }
-}
\ No newline at end of file