blob: e9beb95670d45820c687031a1df3e69747c0250c (
plain)
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
|
// Copyright © Microsoft Corporation.
// This source file is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.
using System;
using System.IO;
using System.Collections.Generic;
namespace Microsoft.Ddue.Tools.CommandLine {
public sealed class StringOption : Option {
private string template = "xxxx";
public StringOption(string name) : base(name) { }
public StringOption(string name, string description) : base(name, description) { }
public StringOption(string name, string description, string template) : base(name, description) {
this.template = template;
}
public string Template {
get {
return (template);
}
set {
template = value;
}
}
internal override ParseResult ParseArgument(string argument) {
if (!(argument.Length > 0)) return (ParseResult.MalformedArgument);
if (argument[0] != ':') return (ParseResult.MalformedArgument);
if (present) return (ParseResult.MultipleOccurance);
present = true;
value = argument.Substring(1);
return (ParseResult.Success);
}
internal override void WriteTemplate(TextWriter writer) {
writer.WriteLine("/{0}:{1}", Name, template);
}
}
}
|