diff options
Diffstat (limited to 'ShiftOS.Main/Terminal/Commands')
| -rw-r--r-- | ShiftOS.Main/Terminal/Commands/Echo.cs | 37 | ||||
| -rw-r--r-- | ShiftOS.Main/Terminal/Commands/Hello.cs | 2 | ||||
| -rw-r--r-- | ShiftOS.Main/Terminal/Commands/Help.cs | 8 | ||||
| -rw-r--r-- | ShiftOS.Main/Terminal/Commands/TestStory.cs | 14 | ||||
| -rw-r--r-- | ShiftOS.Main/Terminal/Commands/codepoints.cs | 33 | ||||
| -rw-r--r-- | ShiftOS.Main/Terminal/Commands/shutdown.cs | 23 | ||||
| -rw-r--r-- | ShiftOS.Main/Terminal/Commands/startx.cs | 57 |
7 files changed, 168 insertions, 6 deletions
diff --git a/ShiftOS.Main/Terminal/Commands/Echo.cs b/ShiftOS.Main/Terminal/Commands/Echo.cs new file mode 100644 index 0000000..37988b7 --- /dev/null +++ b/ShiftOS.Main/Terminal/Commands/Echo.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Main.Terminal.Commands +{ + public class Echo : TerminalCommand + { + public override string Name { get; } = "echo"; + public override string Summary { get; } = "Return a string."; + public override string Usage { get; } = "echo <PHRASE>"; + public override bool Unlocked { get; set; } = true; + + public override void Run(params string[] args) + { + if (args.Length == 0) + { + WriteLine("echo: syntax error"); + return; + } + switch (args[0]) + { + default: + WriteLine(string.Join(" ", args)); + break; + case "off": + Array.Find(TerminalBackend.trm.ToArray(), w => w.TerminalID == TermID).defaulttextResult = ""; + break; + case "on": + Array.Find(TerminalBackend.trm.ToArray(), w => w.TerminalID == TermID).defaulttextResult = "[user@shiftos ~]$ "; + break; + } + } + } +} diff --git a/ShiftOS.Main/Terminal/Commands/Hello.cs b/ShiftOS.Main/Terminal/Commands/Hello.cs index a826532..f4940b5 100644 --- a/ShiftOS.Main/Terminal/Commands/Hello.cs +++ b/ShiftOS.Main/Terminal/Commands/Hello.cs @@ -12,7 +12,7 @@ namespace ShiftOS.Main.Terminal.Commands public override string Name { get; } = "Hello"; public override string Summary { get; } = "Just an example command."; public override string Usage { get; } = "Hello <NAME>."; - public override bool Unlocked { get; set; } = false; + public override bool Unlocked { get; set; } = true; public override void Run(params string[] parameters) { diff --git a/ShiftOS.Main/Terminal/Commands/Help.cs b/ShiftOS.Main/Terminal/Commands/Help.cs index 9067551..b252318 100644 --- a/ShiftOS.Main/Terminal/Commands/Help.cs +++ b/ShiftOS.Main/Terminal/Commands/Help.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,7 +12,7 @@ namespace ShiftOS.Main.Terminal.Commands public override string Name { get; } = "help"; public override string Summary { get; } = "Shows the list of valid commands."; public override string Usage { get; } = "help <command>"; - public override bool Unlocked { get; set; } = false; + public override bool Unlocked { get; set; } = true; public override void Run(params string[] args) { @@ -22,16 +23,17 @@ namespace ShiftOS.Main.Terminal.Commands bool solved = false; foreach (var t in TerminalBackend.instances) { - if (t.Name == args[0]) + if (t.Name.ToLower() == args[0].ToLower()) { solved = true; WriteLine($"{t.Name}: {t.Summary} \n usage: {t.Usage}"); break; } + if (t.Name.ToLower() == args[0].ToLower() && t.Unlocked == false) return; } if (!solved) { - WriteLine($"sbash: invalid token: {args[0]}"); + Write($"sbash: unexpected token: {args[0]}", Color.White); } } } diff --git a/ShiftOS.Main/Terminal/Commands/TestStory.cs b/ShiftOS.Main/Terminal/Commands/TestStory.cs index b6f7f9e..b3c0989 100644 --- a/ShiftOS.Main/Terminal/Commands/TestStory.cs +++ b/ShiftOS.Main/Terminal/Commands/TestStory.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading; @@ -18,10 +19,19 @@ namespace ShiftOS.Main.Terminal.Commands { var r = new Random(); WriteLine($"Incoming connection from {r.Next(0, 256)}.{r.Next(0, 256)}.{r.Next(0, 256)}.{r.Next(0, 256)}..."); - Task.Delay(2000); + WriteLine(); //The various Task.Delay functions are to make the Thread.Sleep function work. + Thread.Sleep(r.Next(2000, 4500)); WriteLine("User set alias as \"DevX\"."); - Thread.Sleep(2000); + Task.Delay(1); + Thread.Sleep(4000); WriteLine("User <DevX> has connected successfully!"); + Task.Delay(1); + Thread.Sleep(3400); + StoryWriteLine("Well, it seems ShiftOS has installed. Congrats.... err... whatever your name is."); + } + private void StoryWriteLine(string value) + { + WriteLine($"[devx@master ~]$ {value}"); } } } diff --git a/ShiftOS.Main/Terminal/Commands/codepoints.cs b/ShiftOS.Main/Terminal/Commands/codepoints.cs new file mode 100644 index 0000000..73dd6c9 --- /dev/null +++ b/ShiftOS.Main/Terminal/Commands/codepoints.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static ShiftOS.Engine.SaveSystem; +using System.IO; + +namespace ShiftOS.Main.Terminal.Commands +{ + public class codepoints : TerminalCommand + { + public override string Name { get; } = "codepoints"; + public override string Summary { get; } = "Shows your current amount of codepoints."; + public override string Usage { get; } = "codepoints"; + public override bool Unlocked { get; set; } = true; + + public override void Run(params string[] parameters) + { + if (parameters.Length > 0) + { + WriteLine($"sbash: unexpected token: {parameters.First()}"); + } + + using (var fs = File.OpenRead(dataDir + "\\userCodePoints.whoa")) + { + int codepoints = Whoa.Whoa.DeserialiseObject<int>(fs, Whoa.SerialisationOptions.None); + WriteLine($"You currently have {codepoints} codepoints."); + } + } + } +} + diff --git a/ShiftOS.Main/Terminal/Commands/shutdown.cs b/ShiftOS.Main/Terminal/Commands/shutdown.cs new file mode 100644 index 0000000..880af1e --- /dev/null +++ b/ShiftOS.Main/Terminal/Commands/shutdown.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShiftOS.Main.Terminal.Commands +{ + class shutdown:TerminalCommand + { + public override string Name { get; } = "shutdown"; + public override string Summary { get; } = "Shuts down and saves ShiftOS."; + public override string Usage { get; } = "shutdown"; + public override bool Unlocked { get; set; } = true; + + public override void Run(params string[] parameters) + { + Application.Exit(); + } + } +} diff --git a/ShiftOS.Main/Terminal/Commands/startx.cs b/ShiftOS.Main/Terminal/Commands/startx.cs new file mode 100644 index 0000000..38a8fdf --- /dev/null +++ b/ShiftOS.Main/Terminal/Commands/startx.cs @@ -0,0 +1,57 @@ +using ShiftOS.Main.ShiftOS; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; +using static ShiftOS.Engine.CodepointUpgrade; +using static ShiftOS.Engine.SaveSystem; + + +namespace ShiftOS.Main.Terminal.Commands +{ + public class startx : TerminalCommand, ICodepointUpgrade + { + private bool hasGUI = false; + private bool autostart = false; + public override string Name { get; } = "startx"; + public override string Summary { get; } = "Starts the ShiftX driver."; + public override string Usage { get; } = "startx"; + public override bool Unlocked { get; set; } = false; + public int codePoints { get; set; } = 150; + + public override void Run(params string[] args) + { + if (args.Length > 0) + { + if (args[0] == "autostart") + { + if (!autostart) + { + WriteLine("startx: Toggled autostart ON."); + return; + } + else + { + WriteLine("startx: Toggled autostart OFF."); + return; + } + } + WriteLine($"sbash: unexpected token: {args[0]}"); + return; + } + if (!hasGUI) + { + var d = new Desktop(); + d.Show(); + hasGUI = true; + } + if (hasGUI == true) + { + WriteLine("The ShiftX driver has already been intialized."); + return; + } + } + } +} |
