-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCmdLineArguments.cs
More file actions
64 lines (55 loc) · 1.51 KB
/
CmdLineArguments.cs
File metadata and controls
64 lines (55 loc) · 1.51 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/********************************************************
* *
* Copyright (C) Microsoft. All rights reserved. *
* *
*********************************************************/
using System;
namespace Microsoft.Partner.CSP.IntSandbox.Customer.Sample
{
class CmdLineArguments
{
[Argument(ArgumentType.Required, ShortName = "op", HelpText = "Operation to perform")]
public Operation operation;
[Argument(ArgumentType.AtMostOnce, HelpText = "File to write (export) or read (DeleteSelected)")]
public string file;
[Argument(ArgumentType.AtMostOnce, HelpText = "Suppress confirmation prompt on delete operations; Overwrite file on Export")]
public bool confirm;
internal bool Validate()
{
if (operation == Operation.Export || operation == Operation.Delete)
{
if (String.IsNullOrEmpty(file))
{
Console.WriteLine("File is required for Export or Delete");
return false;
}
}
if (operation == Operation.Export)
{
if (System.IO.File.Exists(file))
{
if (confirm == false)
{
Console.WriteLine("File specified already exists");
return false;
}
}
}
if (operation == Operation.Delete && !String.IsNullOrEmpty(file))
{
if (!System.IO.File.Exists(file))
{
Console.WriteLine("File specified does not exist");
return false;
}
}
return true;
}
}
enum Operation
{
Export,
Delete,
DeleteAll
}
}