mirror of
https://github.com/tonytins/tomas.git
synced 2025-03-15 04:11:24 +00:00
.NET 6 quality of life changes to Tomas.Common
- Split and simplified version details - Raw commit hash is now a build number based on that hash
This commit is contained in:
parent
69fcc9c776
commit
a029d8d4d9
13 changed files with 81 additions and 79 deletions
|
@ -1,15 +1,29 @@
|
|||
// I license this project under the BSD 3-Clause license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
namespace Tomas.Common
|
||||
{
|
||||
public struct ComConsts
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the operating system
|
||||
/// </summary>
|
||||
public const string NAME = "TOMAS";
|
||||
using System.Text;
|
||||
|
||||
public static string Version = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}";
|
||||
public static string VersionGit = $"{Version}-{ThisAssembly.Git.Commit}";
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
2
src/Tomas.Common/GlobalUsing.cs
Normal file
2
src/Tomas.Common/GlobalUsing.cs
Normal file
|
@ -0,0 +1,2 @@
|
|||
global using System.Diagnostics.CodeAnalysis;
|
||||
global using Tomas.Interface;
|
|
@ -1,16 +1,13 @@
|
|||
// 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.Interface;
|
||||
|
||||
namespace Tomas.Common.Programs
|
||||
namespace Tomas.Common.Programs;
|
||||
|
||||
public class Clear : IProgram
|
||||
{
|
||||
public class Clear : IProgram
|
||||
{
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
Console.Clear();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
Console.Clear();
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,19 +1,16 @@
|
|||
// 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.Interface;
|
||||
|
||||
namespace Tomas.Common.Programs
|
||||
namespace Tomas.Common.Programs;
|
||||
|
||||
public class Commands : IProgram
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
Console.WriteLine($"Commands:");
|
||||
var progs = shell.Programs;
|
||||
foreach (var commands in progs.Keys)
|
||||
Console.WriteLine(commands);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -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 System;
|
||||
using Tomas.Interface;
|
||||
|
||||
namespace Tomas.Common.Programs
|
||||
namespace Tomas.Common.Programs;
|
||||
|
||||
public class FenSay : IProgram
|
||||
{
|
||||
public class FenSay : IProgram
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Fennec art by Todd Vargo
|
||||
/// </summary>
|
||||
const string _fennec = @" \/
|
||||
/// <summary>
|
||||
/// Fennec art by Todd Vargo
|
||||
/// </summary>
|
||||
const string _fennec = @" \/
|
||||
/\ /\
|
||||
//\\_//\\ ____
|
||||
\_ _/ / /
|
||||
|
@ -22,20 +20,19 @@ namespace Tomas.Common.Programs
|
|||
[ [ / \/ _/
|
||||
_[ [ \ /_/";
|
||||
|
||||
readonly string[] _phrases =
|
||||
{
|
||||
"[SCREAMS IN FENNEC]",
|
||||
"Some people call me a coffee fox.",
|
||||
"Drink Soda. It makes you see faster.",
|
||||
"10/10, Wouldn't Recommend."
|
||||
};
|
||||
readonly string[] _phrases =
|
||||
{
|
||||
"[SCREAMS IN FENNEC]",
|
||||
"Some people call me a coffee fox.",
|
||||
"Drink Soda. It makes you see faster.",
|
||||
"10/10, Wouldn't Recommend."
|
||||
};
|
||||
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
var rng = new Random();
|
||||
var phrases = _phrases[rng.Next(_phrases.Length)];
|
||||
Console.WriteLine($"{phrases}{Environment.NewLine}{_fennec}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
var rng = new Random();
|
||||
var phrases = _phrases[rng.Next(_phrases.Length)];
|
||||
Console.WriteLine($"{phrases}{Environment.NewLine}{_fennec}");
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,18 +1,19 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Tomas.Interface\Tomas.Interface.csproj" />
|
||||
<ProjectReference Include="..\Tomas.Interface\Tomas.Interface.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GitInfo" Version="2.1.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="GitInfo" Version="2.1.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
global using Tomas.Common.Programs;
|
||||
global using Tomas.Interface;
|
||||
global using Tomas.Kernel;
|
||||
global using Tomas.Kernel.Programs;
|
||||
global using Os = Cosmos.System;
|
|
@ -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 System;
|
||||
|
||||
namespace Tomas.Kernel;
|
||||
|
||||
|
|
|
@ -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 System;
|
||||
using Tomas.Common;
|
||||
|
||||
namespace Tomas.Kernel.Programs;
|
||||
|
@ -9,7 +8,7 @@ public class About : IProgram
|
|||
{
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
Console.WriteLine($"TOMAS v{ComConsts.VersionGit} is a hobby operating system written in C# using the COSMOS framework.{Environment.NewLine}Commands:");
|
||||
Console.WriteLine($"TOMAS v{ComConsts.VERSION} ({ComConsts.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);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// 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;
|
||||
|
||||
namespace Tomas.Kernel;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// 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.IO;
|
||||
using Cosmos.System.FileSystem;
|
||||
using Cosmos.System.FileSystem.VFS;
|
||||
using Tomas.Common;
|
||||
|
@ -23,7 +21,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.VersionGit}");
|
||||
File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{ComConsts.NAME}, {ComConsts.BuildNumber}");
|
||||
Console.WriteLine("File system loaded sucesfully.");
|
||||
var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
|
||||
Console.WriteLine(intro);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
@ -6,6 +6,7 @@
|
|||
<Platform>cosmos</Platform>
|
||||
<SupportsX86Intrinsics>false</SupportsX86Intrinsics>
|
||||
<SelfContained>True</SelfContained>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -26,8 +27,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<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>
|
||||
|
|
|
@ -8,7 +8,7 @@ public class About : IProgram
|
|||
{
|
||||
public bool Run(IShell shell)
|
||||
{
|
||||
Console.WriteLine($"{ComConsts.NAME} Terminal Emulator v{ComConsts.VersionGit}{Environment.NewLine}"
|
||||
Console.WriteLine($"{ComConsts.NAME} Terminal Emulator v{ComConsts.BuildNumber}{Environment.NewLine}"
|
||||
+ "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework.");
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue