Skip to content

Commit 23c1d8e

Browse files
committed
Removing commented code, getting demo to compile.
1 parent 1fddaa9 commit 23c1d8e

File tree

3 files changed

+7
-100
lines changed

3 files changed

+7
-100
lines changed

CommandLine.sln.DotSettings.user

+1-1
Large diffs are not rendered by default.

src/demo/Program.cs

+5-38
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#region License
2-
//
3-
// Command Line Library: Program.cs
4-
//
5-
// Author:
6-
// Giacomo Stelluti Scala (gsscoder@gmail.com)
7-
//
8-
// Copyright (C) 2005 - 2013 Giacomo Stelluti Scala
2+
// <copyright file="Program.cs" company="Giacomo Stelluti Scala">
3+
// Copyright 2015-2013 Giacomo Stelluti Scala
4+
// </copyright>
95
//
106
// Permission is hereby granted, free of charge, to any person obtaining a copy
117
// of this software and associated documentation files (the "Software"), to deal
@@ -24,26 +20,15 @@
2420
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2521
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2622
// THE SOFTWARE.
27-
//
2823
#endregion
29-
//#define EXEC_TESTS
3024
#region Using Directives
3125
using System;
32-
using System.Collections.Generic;
33-
using System.ComponentModel;
3426
using System.Text;
35-
using CommandLine;
3627
using CommandLine.Text;
37-
#if EXEC_TESTS
38-
using CommandLine.Tests;
39-
using CommandLine.Text.Tests;
40-
#endif
4128
#endregion
4229

4330
namespace CommandLine.Demo
4431
{
45-
46-
4732
sealed partial class Program
4833
{
4934
private static readonly HeadingInfo HeadingInfo = new HeadingInfo("sampleapp", "1.8");
@@ -54,16 +39,9 @@ sealed partial class Program
5439
/// <param name="args">Command line arguments splitted by the system.</param>
5540
private static void Main(string[] args)
5641
{
57-
#if EXEC_TESTS
58-
RunATestForDebugging();
59-
#endif
60-
var options = new Options();
61-
var parser = new CommandLine.Parser(with => with.HelpWriter = Console.Error);
42+
var options = CommandLine.Parser.Default.ParseArguments<Options>(args, () => Environment.Exit(-2));
6243

63-
if (parser.ParseArgumentsStrict(args, options, () => Environment.Exit(-2)))
64-
{
65-
Run(options);
66-
}
44+
Run(options);
6745
}
6846

6947
private static void Run(Options options)
@@ -118,16 +96,5 @@ private static void Run(Options options)
11896
Console.WriteLine("[...]");
11997
}
12098
}
121-
122-
#if EXEC_TESTS
123-
private static void RunATestForDebugging()
124-
{
125-
//var test = new {XYZ}Fixture();
126-
//test.ExecUnitTestMethod("but set a breakpoint before!");
127-
Console.Write("press any key");
128-
Console.ReadKey();
129-
Environment.Exit(1);
130-
}
131-
#endif
13299
}
133100
}

src/libcmdline/Parser.cs

+1-61
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ namespace CommandLine
4141
/// </summary>
4242
public sealed class Parser : IDisposable
4343
{
44-
///// <summary>
45-
///// Default exit code (1) used by <see cref="Parser.ParseArgumentsStrict(string[],object,Action)"/>
46-
///// and <see cref="Parser.ParseArgumentsStrict(string[],object,Action&lt;string,object&gt;,Action)"/> overloads.
47-
///// </summary>
48-
//public const int DefaultExitCodeFail = 1;
4944
private static readonly Parser DefaultParser = new Parser(true);
5045
private readonly ParserSettings _settings;
5146
private bool _disposed;
@@ -121,60 +116,6 @@ public static Parser Default
121116
get { return DefaultParser; }
122117
}
123118

124-
///// <summary>
125-
///// Gets the instance that implements <see cref="CommandLine.ParserSettings"/> in use.
126-
///// </summary>
127-
//public ParserSettings Settings
128-
//{
129-
// get { return _settings; }
130-
//}
131-
132-
///// <summary>
133-
///// Parses a <see cref="System.String"/> array of command line arguments, setting values in <paramref name="options"/>
134-
///// parameter instance's public fields decorated with appropriate attributes.
135-
///// </summary>
136-
///// <param name="args">A <see cref="System.String"/> array of command line arguments.</param>
137-
///// <param name="options">An instance used to receive values.
138-
///// Parsing rules are defined using <see cref="CommandLine.BaseOptionAttribute"/> derived types.</param>
139-
///// <returns>True if parsing process succeed.</returns>
140-
///// <exception cref="System.ArgumentNullException">Thrown if <paramref name="args"/> is null.</exception>
141-
///// <exception cref="System.ArgumentNullException">Thrown if <paramref name="options"/> is null.</exception>
142-
//public bool ParseArguments(string[] args, object options)
143-
//{
144-
// Assumes.NotNull(args, "args", SR.ArgumentNullException_ArgsStringArrayCannotBeNull);
145-
// Assumes.NotNull(options, "options", SR.ArgumentNullException_OptionsInstanceCannotBeNull);
146-
147-
// return DoParseArguments(args, options);
148-
//}
149-
150-
///// <summary>
151-
///// Parses a <see cref="System.String"/> array of command line arguments with verb commands, setting values in <paramref name="options"/>
152-
///// parameter instance's public fields decorated with appropriate attributes.
153-
///// This overload supports verb commands.
154-
///// </summary>
155-
///// <param name="args">A <see cref="System.String"/> array of command line arguments.</param>
156-
///// <param name="options">An instance used to receive values.
157-
///// Parsing rules are defined using <see cref="CommandLine.BaseOptionAttribute"/> derived types.</param>
158-
///// <param name="onVerbCommand">Delegate executed to capture verb command name and instance.</param>
159-
///// <returns>True if parsing process succeed.</returns>
160-
///// <exception cref="System.ArgumentNullException">Thrown if <paramref name="args"/> is null.</exception>
161-
///// <exception cref="System.ArgumentNullException">Thrown if <paramref name="options"/> is null.</exception>
162-
///// <exception cref="System.ArgumentNullException">Thrown if <paramref name="onVerbCommand"/> is null.</exception>
163-
//public bool ParseArguments(string[] args, object options, Action<string, object> onVerbCommand)
164-
//{
165-
// Assumes.NotNull(args, "args", SR.ArgumentNullException_ArgsStringArrayCannotBeNull);
166-
// Assumes.NotNull(options, "options", SR.ArgumentNullException_OptionsInstanceCannotBeNull);
167-
// Assumes.NotNull(options, "onVerbCommand", SR.ArgumentNullException_OnVerbDelegateCannotBeNull);
168-
169-
// object verbInstance = null;
170-
171-
// var result = DoParseArgumentsVerbs(args, options, ref verbInstance);
172-
173-
// onVerbCommand(args.FirstOrDefault() ?? string.Empty, result ? verbInstance : null);
174-
175-
// return result;
176-
//}
177-
178119
/// <summary>
179120
/// Parses a <see cref="System.String"/> array of command line arguments, setting values in <paramref name="options"/>
180121
/// parameter instance's public fields decorated with appropriate attributes. If parsing fails, the method invokes
@@ -405,7 +346,6 @@ private Tuple<bool,T> DoParseArgumentsCore<T>(string[] args, T options)
405346

406347
hadError |= !optionMap.EnforceRules();
407348

408-
//return !hadError ? options : default(T);
409349
return new Tuple<bool, T>(!hadError, options);
410350
}
411351

@@ -457,7 +397,7 @@ private Tuple<bool, T, object> DoParseArgumentsVerbs<T>(string[] args)
457397
var resultAndVerbInstance = DoParseArgumentsCore(args.Skip(1).ToArray(), verbInstance);
458398
var result = resultAndVerbInstance.Item1;
459399
verbInstance = resultAndVerbInstance.Item2;
460-
//if (verbInstance == null && helpInfo != null)
400+
461401
if (!result && helpInfo != null)
462402
{
463403
// Particular verb parsing failed, we try to print its help

0 commit comments

Comments
 (0)