generated from lcpluginmaker/PluginTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexec.cs
More file actions
40 lines (35 loc) · 1.16 KB
/
exec.cs
File metadata and controls
40 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using ILeoConsole;
using ILeoConsole.Core;
namespace LeoConsole_External
{
public class Exec : ICommand
{
public string Name { get { return "exec"; } }
public string Description { get { return "execute arbitrary command or program"; } }
public Action CommandFunction { get { return () => Command(); } }
public Action HelpFunction { get { return () => Console.WriteLine("not available"); } }
private string[] _Arguments;
public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } }
public IData data = new ConsoleData();
public void Command()
{
if (_Arguments.Length < 2)
{
LConsole.MessageErr0("you need to provide the command to run");
return;
}
string command = _Arguments[1];
string args = "";
for (int i = 2; i < _Arguments.Length; i++)
{
args = $"{args} {_Arguments[i]}";
}
LConsole.MessageSuc0($"executing {command}{args}...");
if (Processes.Run(command, args, data.SavePath) != 0)
{
LConsole.MessageErr0($"cannot execute {command}");
}
}
}
}
// vim: tabstop=2 softtabstop=2 shiftwidth=2 expandtab