Skip to content

Commit

Permalink
add - doc - Backported Nitrocid's shell to Termina...
Browse files Browse the repository at this point in the history
...ux

---

We've backported the shell implementation in to satisfy the requirements,
removing some of Nitrocid-exclusive features in the process as they're out
of scope for Terminaux. Nitrocid KS will not use it as it has its own
shell implementation.

---

Type: add
Breaking: False
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Nov 17, 2024
1 parent 9faf1b3 commit 90b86a2
Show file tree
Hide file tree
Showing 79 changed files with 596 additions and 5,486 deletions.
30 changes: 30 additions & 0 deletions Terminaux.Console/Fixtures/Cases/Shell/Shells/Commands/Write.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Nitrocid KS Copyright (C) 2018-2024 Aptivi
//
// This file is part of Nitrocid KS
//
// Nitrocid KS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Nitrocid KS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Terminaux.Shell.Commands;
using Terminaux.Writer.ConsoleWriters;

namespace Terminaux.Console.Fixtures.Cases.Shell.Shells.Commands
{
class WriteCommand : BaseCommand, ICommand
{
public override void Execute(CommandParameters parameters) =>
TextWriterColor.Write("Test text");
}
}
30 changes: 30 additions & 0 deletions Terminaux.Console/Fixtures/Cases/Shell/Shells/Commands/WriteArg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Nitrocid KS Copyright (C) 2018-2024 Aptivi
//
// This file is part of Nitrocid KS
//
// Nitrocid KS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Nitrocid KS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Terminaux.Shell.Commands;
using Terminaux.Writer.ConsoleWriters;

namespace Terminaux.Console.Fixtures.Cases.Shell.Shells.Commands
{
class WriteArgCommand : BaseCommand, ICommand
{
public override void Execute(CommandParameters parameters) =>
TextWriterColor.Write(parameters.ArgumentsText);
}
}
55 changes: 55 additions & 0 deletions Terminaux.Console/Fixtures/Cases/Shell/Shells/TestShellInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Terminaux Copyright (C) 2023-2024 Aptivi
//
// This file is part of Terminaux
//
// Terminaux is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Terminaux is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terminaux.Console.Fixtures.Cases.Shell.Shells.Commands;
using Terminaux.Shell.Arguments;
using Terminaux.Shell.Commands;
using Terminaux.Shell.Shells;

namespace Terminaux.Console.Fixtures.Cases.Shell.Shells
{
internal class TestShellInfo : BaseShellInfo, IShellInfo
{
/// <summary>
/// List of commands
/// </summary>
public override List<CommandInfo> Commands =>
[
new CommandInfo("write", "Writes test text",
[
new CommandArgumentInfo()
], new WriteCommand()),

new CommandInfo("writearg", "Writes test text with argument support",
[
new CommandArgumentInfo(
[
new CommandArgumentPart(true, "text")
])
], new WriteArgCommand()),
];

public override BaseShell ShellBase => new TestShellInstance();
}
}
61 changes: 61 additions & 0 deletions Terminaux.Console/Fixtures/Cases/Shell/Shells/TestShellInstance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// Terminaux Copyright (C) 2023-2024 Aptivi
//
// This file is part of Terminaux
//
// Terminaux is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Terminaux is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY, without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Terminaux.Shell.Shells;
using Terminaux.Writer.ConsoleWriters;
using Textify.General;

namespace Terminaux.Console.Fixtures.Cases.Shell.Shells
{
internal class TestShellInstance : BaseShell, IShell
{
/// <inheritdoc/>
public override string ShellType => "TestShell";

/// <inheritdoc/>
public override bool Bail { get; set; }

/// <inheritdoc/>
public override void InitializeShell(params object[] ShellArgs)
{
while (!Bail)
{
try
{
ShellManager.GetLine();
}
catch (ThreadInterruptedException)
{
Bail = true;
}
catch (Exception ex)
{
TextWriterRaw.WritePlain("There was an error in the shell." + CharManager.NewLine + "Error {0}: {1}", ex.GetType().FullName ?? "<null>", ex.Message);
continue;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,30 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Terminaux.Shell.Commands;
using System;
using System.Text;
using Terminaux.Base;
using Terminaux.Base.Buffered;
using Terminaux.Colors;
using Terminaux.Colors.Data;
using Terminaux.Inputs.Styles.Infobox;
using Terminaux.Inputs;
using Terminaux.Sequences.Builder.Types;
using Terminaux.Base.Extensions;
using Terminaux.Shell.Shells;
using Terminaux.Console.Fixtures.Cases.Shell.Shells;

namespace Terminaux.Shell.Shells.Unified
namespace Terminaux.Console.Fixtures.Cases.Shell
{
/// <summary>
/// Saves shell histories
/// </summary>
/// <remarks>
/// You can use this command to save shell histories.
/// </remarks>
class SaveHistoriesUnifiedCommand : BaseCommand, ICommand
internal class TestShell : IFixture
{
public FixtureCategory Category => FixtureCategory.Shell;

public override int Execute(CommandParameters parameters, ref string variableValue)
public void RunFixture()
{
ShellManager.SaveHistories();
return 0;
ShellManager.RegisterShell("TestShell", new TestShellInfo());
ShellManager.StartShell("TestShell");
ShellManager.UnregisterShell("TestShell");
}

}
}
3 changes: 2 additions & 1 deletion Terminaux.Console/Fixtures/FixtureCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ internal enum FixtureCategory
Presentation,
Console,
Image,
Graphics
Graphics,
Shell,
}
}
4 changes: 4 additions & 0 deletions Terminaux.Console/Fixtures/FixtureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Terminaux.Console.Fixtures.Cases.Presentations;
using Terminaux.Console.Fixtures.Cases.Reader;
using Terminaux.Console.Fixtures.Cases.Screens;
using Terminaux.Console.Fixtures.Cases.Shell;
using Terminaux.Console.Fixtures.Cases.Tui;
using Terminaux.Console.Fixtures.Cases.Writer;

Expand Down Expand Up @@ -321,6 +322,9 @@ internal static class FixtureManager
new RenderEllipsis(),
new RenderCircle(),
new RenderArc(),

// Shell
new TestShell(),
];
}
}
Loading

0 comments on commit 90b86a2

Please sign in to comment.