summaryrefslogtreecommitdiffstats
path: root/tools/Sandcastle/Source/CommandLine/SwitchOption.cs
blob: 394d137cf23a6f3bb315fd954be4f7c6bfc03dfe (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
// 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 SwitchOption : Option {

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

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

        internal override ParseResult ParseArgument(string argument) {
            if (argument.Length > 0) return (ParseResult.MalformedArgument);
            if (present) return (ParseResult.MultipleOccurance);
            present = true;
            return (ParseResult.Success);
        }

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

    }

}