2017-11-19 00:32:37 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ShiftOS.Main.Terminal.Commands
|
|
|
|
|
{
|
|
|
|
|
public class Help : TerminalCommand
|
|
|
|
|
{
|
|
|
|
|
public override string Name { get; } = "help";
|
|
|
|
|
public override string Summary { get; } = "Shows the list of valid commands.";
|
2017-11-21 22:12:50 +00:00
|
|
|
|
public override string Usage { get; } = "help <command>";
|
2017-11-19 00:32:37 +00:00
|
|
|
|
public override bool Unlocked { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
public override void Run(params string[] args)
|
|
|
|
|
{
|
2017-11-21 22:12:50 +00:00
|
|
|
|
if (args.Length > 0)
|
2017-11-19 00:32:37 +00:00
|
|
|
|
{
|
2017-11-21 22:12:50 +00:00
|
|
|
|
if (args[0] != null && args[0] != "")
|
|
|
|
|
{
|
|
|
|
|
bool solved = false;
|
|
|
|
|
foreach (var t in TerminalBackend.instances)
|
|
|
|
|
{
|
|
|
|
|
if (t.Name == args[0])
|
|
|
|
|
{
|
|
|
|
|
solved = true;
|
2017-11-23 17:20:53 +00:00
|
|
|
|
WriteLine($"{t.Name}: {t.Summary} \n usage: {t.Usage}");
|
2017-11-21 22:12:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!solved)
|
|
|
|
|
{
|
2017-11-23 17:20:53 +00:00
|
|
|
|
WriteLine($"sbash: invalid token: {args[0]}");
|
2017-11-21 22:12:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-11-21 22:32:56 +00:00
|
|
|
|
WriteLine("List of valid commands for ShiftOS. \n To get help for a specific command, type \"help <command>\".\r\n");
|
2017-11-21 22:12:50 +00:00
|
|
|
|
foreach (var t in TerminalBackend.instances)
|
|
|
|
|
{
|
|
|
|
|
WriteLine($"{t.Name}: {t.Summary}");
|
|
|
|
|
}
|
2017-11-19 00:32:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|