-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfirmConsoleCommand.cs
41 lines (37 loc) · 1.23 KB
/
ConfirmConsoleCommand.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
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Irisys.BlackfinAPI;
namespace BlackfinAPIConsole
{
/// <summary>
/// Convenience class for commands with no arguments which require a confirmation message
/// </summary>
public abstract class ConfirmConsoleCommand : BaseConsoleCommand{
public ConfirmConsoleCommand(String name, String help)
: base(name, help, new String[] { "[y/n]\nAre you sure you want to " + name })
{
}
/// <summary>
/// Ask the user to confirm they want to continue, then call abstract execute function
/// </summary>
/// <param name="bf"></param>
/// <param name="args"></param>
/// <returns></returns>
public override String execute(Blackfin bf, String[] args)
{
if (args[0].ToLower().Equals("y"))
{
execute(bf);
}
return "user cancelled ("+args[0]+")";
}
/// <summary>
/// The argumentless function to execute upon confirmation
/// </summary>
/// <param name="bf"></param>
/// <returns></returns>
public abstract String execute(Blackfin bf);
}
}