mirror of
https://github.com/tonytins/tomas.git
synced 2025-06-25 18:14:42 -04:00
Use latest quality of life changes in .NET 6 for the Terminal emulator
- Similar project changes to the kernal and resepctive assemblies will be taken more slowly
This commit is contained in:
parent
3deec1773f
commit
7530f8500b
7 changed files with 63 additions and 68 deletions
2
src/Tomas.Terminal/GlobalUsing.cs
Normal file
2
src/Tomas.Terminal/GlobalUsing.cs
Normal file
|
@ -0,0 +1,2 @@
|
|||
global using Tomas.Common.Programs;
|
||||
global using Tomas.Interface;
|
|
@ -1,42 +1,40 @@
|
|||
// 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.
|
||||
using System;
|
||||
|
||||
namespace Tomas.Terminal
|
||||
namespace Tomas.Terminal;
|
||||
|
||||
class Program
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var shell = new Shell();
|
||||
var command = shell.ReadLine;
|
||||
var programs = shell.Programs;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
Console.WriteLine(err.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
// 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.Terminal.Programs
|
||||
{
|
||||
public class About : IProgram
|
||||
public class About : IProgram
|
||||
{
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
|
|
|
@ -1,33 +1,28 @@
|
|||
// 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.Terminal.Programs;
|
||||
|
||||
namespace Tomas.Terminal
|
||||
namespace Tomas.Terminal;
|
||||
|
||||
public class Shell : IShell
|
||||
{
|
||||
public class Shell : IShell
|
||||
{
|
||||
const char SYMBOL = '$';
|
||||
const char SYMBOL = '$';
|
||||
|
||||
public Dictionary<string, IProgram> Programs => new Dictionary<string, IProgram>()
|
||||
public Dictionary<string, IProgram> Programs => new()
|
||||
{
|
||||
{"about", new About()},
|
||||
{"fensay", new FenSay()},
|
||||
{"clear", new Clear()},
|
||||
{"commands", new Commands()}
|
||||
};
|
||||
|
||||
public string ReadLine
|
||||
{
|
||||
get
|
||||
{
|
||||
{"about", new About()},
|
||||
{"fensay", new FenSay()},
|
||||
{"clear", new Clear()},
|
||||
{"commands", new Commands()}
|
||||
};
|
||||
|
||||
public string ReadLine
|
||||
{
|
||||
get
|
||||
{
|
||||
Console.Write(SYMBOL);
|
||||
var readl = Console.ReadLine();
|
||||
return readl;
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.Write(SYMBOL);
|
||||
var readl = Console.ReadLine();
|
||||
return readl;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,13 +3,13 @@
|
|||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>8</LangVersion>
|
||||
<Nullable>warnings</Nullable>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Tomas.Common\Tomas.Common.csproj" />
|
||||
<ProjectReference Include="..\Tomas.Interface\Tomas.Interface.csproj" />
|
||||
<ProjectReference Include="..\Tomas.Common\Tomas.Common.csproj" />
|
||||
<ProjectReference Include="..\Tomas.Interface\Tomas.Interface.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue