aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Engine
diff options
context:
space:
mode:
authorjtsshieh <[email protected]>2017-11-18 11:56:23 -0500
committerGitHub <[email protected]>2017-11-18 11:56:23 -0500
commitce700260e681f483e8e7120619f690da2d8847a6 (patch)
tree6897964ac67014fd497ee4f8c29c0ba1742ba5d5 /ShiftOS.Engine
parent97722fbe9d474adffbba0b92e9727c48a8205234 (diff)
parentc0400bc229d5f275955d6c964108deebf0908b4b (diff)
downloadshiftos-rewind-ce700260e681f483e8e7120619f690da2d8847a6.tar.gz
shiftos-rewind-ce700260e681f483e8e7120619f690da2d8847a6.tar.bz2
shiftos-rewind-ce700260e681f483e8e7120619f690da2d8847a6.zip
Merge pull request #15 from Alex-TIMEHACK/master
Fully working command handler (Alex)
Diffstat (limited to 'ShiftOS.Engine')
-rw-r--r--ShiftOS.Engine/ShiftOS.Engine.csproj3
-rw-r--r--ShiftOS.Engine/Terminal/Commands/Hello.cs9
-rw-r--r--ShiftOS.Engine/Terminal/TerminalBackend.cs47
-rw-r--r--ShiftOS.Engine/Terminal/TerminalCommand.cs9
4 files changed, 0 insertions, 68 deletions
diff --git a/ShiftOS.Engine/ShiftOS.Engine.csproj b/ShiftOS.Engine/ShiftOS.Engine.csproj
index 0bb54c5..88ad0cf 100644
--- a/ShiftOS.Engine/ShiftOS.Engine.csproj
+++ b/ShiftOS.Engine/ShiftOS.Engine.csproj
@@ -69,9 +69,6 @@
<Compile Include="ShiftFS\ShiftFile.cs" />
<Compile Include="ShiftFS\ShiftFS.cs" />
<Compile Include="ShiftFS\IShiftNode.cs" />
- <Compile Include="Terminal\Commands\Hello.cs" />
- <Compile Include="Terminal\TerminalBackend.cs" />
- <Compile Include="Terminal\TerminalCommand.cs" />
<Compile Include="Misc\Tools.cs" />
<Compile Include="WindowManager\InfoboxTemplate.cs">
<SubType>UserControl</SubType>
diff --git a/ShiftOS.Engine/Terminal/Commands/Hello.cs b/ShiftOS.Engine/Terminal/Commands/Hello.cs
deleted file mode 100644
index 7d4b82f..0000000
--- a/ShiftOS.Engine/Terminal/Commands/Hello.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace ShiftOS.Engine.Terminal.Commands
-{
- public class Hello : TerminalCommand
- {
- public override string GetName() => "Hello";
-
- public override string Run(params string[] parameters) => "Oh, HELLO, " + string.Join(" ", parameters);
- }
-} \ No newline at end of file
diff --git a/ShiftOS.Engine/Terminal/TerminalBackend.cs b/ShiftOS.Engine/Terminal/TerminalBackend.cs
deleted file mode 100644
index 793b748..0000000
--- a/ShiftOS.Engine/Terminal/TerminalBackend.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace ShiftOS.Engine.Terminal
-{
- public static class TerminalBackend
- {
- // The line below gets all the terminal commands in... well... the entire ShiftOS.Engine
- static readonly IEnumerable<TerminalCommand> Instances = from t in Assembly.GetExecutingAssembly().GetTypes()
- where t.IsSubclassOf(typeof(TerminalCommand)) &&
- t.GetConstructor(Type.EmptyTypes) != null
- select (TerminalCommand) Activator.CreateInstance(t);
-
- /// <summary>
- /// Runs a terminal command.
- /// </summary>
- /// <param name="command"></param>
- /// <returns>Returns all the output from that command.</returns>
- public static string RunCommand(string command)
- {
- string name;
- try
- {
- name = command.Split(' ')[0];
- }
- catch
- {
- name = command;
- }
-
- var theParams = new string[command.Split(' ').Length - 1];
- Array.Copy(command.Split(' '), 1, theParams, 0, command.Split(' ').Length - 1);
-
- foreach (var instance in Instances)
- {
- if (instance.GetName() == name)
- {
- return instance.Run(theParams);
- }
- }
-
- return "The command cannot be found.";
- }
- }
-} \ No newline at end of file
diff --git a/ShiftOS.Engine/Terminal/TerminalCommand.cs b/ShiftOS.Engine/Terminal/TerminalCommand.cs
deleted file mode 100644
index 81a34b9..0000000
--- a/ShiftOS.Engine/Terminal/TerminalCommand.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace ShiftOS.Engine.Terminal
-{
- public abstract class TerminalCommand
- {
- public abstract string GetName();
-
- public abstract string Run(params string[] parameters);
- }
-} \ No newline at end of file