summaryrefslogtreecommitdiffstats
path: root/tools/Sandcastle/Source/CommandLine/BooleanOption.cs
blob: 6ea23a19d3b2f9da91967a0d3a23bc1b6cb592ae (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
// 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 BooleanOption : Option {

        public BooleanOption(string name) : base(name) { }

        public BooleanOption(string name, string description) : base(name, description) { }

        internal override ParseResult ParseArgument(string argument) {
            if ((argument != "+") && (argument != "-")) return (ParseResult.MalformedArgument);
            if (present) return (ParseResult.MultipleOccurance);
            present = true;
            if (argument == "+") {
                value = true;
            } else {
                value = false;
            }
            return (ParseResult.Success);
        }

        internal override void WriteTemplate(TextWriter writer) {
            writer.WriteLine("/{0}+|-", Name);
        }

    }

}