-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsleep.cs
33 lines (30 loc) · 1001 Bytes
/
sleep.cs
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
using System.IO;
using System.Threading;
using ILeoConsole;
using ILeoConsole.Plugin;
using ILeoConsole.Core;
namespace LeoConsole_ExamplePlugin {
public class Sleep : ICommand {
public string Name { get { return "sleep"; } }
public string Description { get { return "do nothing for given number of seconds"; } }
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 void Command() {
int dur;
if (_Arguments.Length < 2) {
dur = 1;
} else {
try {
dur = Int32.Parse(_Arguments[1]);
} catch (Exception e) {
Console.WriteLine("invalid number provided");
return;
}
}
Thread.Sleep(dur * 1000);
}
}
}
// vim: tabstop=2 softtabstop=2 shiftwidth=2 expandtab