Permalink
Browse files

Rough-in NDesk.Options.

  • Loading branch information...
spraints committed Jan 28, 2012
1 parent 9299d2c commit 157676c473e3c4f2fbe7b46aa122b3afb83ff1cc
@@ -3,6 +3,7 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -25,6 +26,11 @@ public Bootstrap(RemoteOptions remoteOptions, Globals globals, TextWriter stdout
_stdout = stdout;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(_remoteOptions); }
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
@@ -19,6 +20,11 @@ protected CheckinBase(TextWriter stdout, CheckinOptions checkinOptions, TfsWrite
_writer = writer;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(_checkinOptions); }
@@ -56,4 +62,4 @@ private int PerformCheckin(TfsChangesetInfo parentChangeset, string refToCheckin
protected abstract long DoCheckin(TfsChangesetInfo changeset, string refToCheckin);
}
-}
+}
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using Sep.Git.Tfs.Core.TfsInterop;
@@ -19,6 +20,11 @@ public Cleanup(CleanupWorkspaces cleanupWorkspaces)
_cleanupWorkspaces = cleanupWorkspaces;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(_cleanupWorkspaces); }
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -24,6 +25,11 @@ public CleanupWorkspaces(TextWriter stdout, Globals globals, CleanupOptions clea
_cleanupOptions = cleanupOptions;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(_cleanupOptions); }
View
@@ -4,6 +4,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -26,6 +27,11 @@ public Clone(Globals globals, Fetch fetch, Init init)
this.globals = globals;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(init, fetch); }
@@ -103,4 +109,4 @@ private static void CleanDirectory(string gitRepositoryPath)
fileSystemInfo.Delete();
}
}
-}
+}
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using NDesk.Options;
using CommandLine.OptParse;
using StructureMap;
@@ -18,6 +19,11 @@ public Diagnostics(TextWriter stdout, IContainer container)
_container = container;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(); }
View
@@ -5,6 +5,7 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -39,6 +40,11 @@ public Fetch(Globals globals, RemoteOptions remoteOptions, FcOptions fcOptions)
[ShortOptionName('p')]
public bool parents { get; set; }
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(fcOptions, remoteOptions); }
View
@@ -3,6 +3,7 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using Sep.Git.Tfs.Util;
@@ -28,6 +29,11 @@ public Help(TextWriter output, GitTfsCommandFactory commandFactory, IContainer c
_container = container;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return null; }
@@ -85,13 +91,19 @@ public int Run(GitTfsCommand command)
if (command is Help)
return Run();
+ output.WriteLine("Usage: git-tfs " + GetCommandUsage(command));
+
+ // deprecated
var usage = new UsageBuilder();
usage.BeginSection("where options are:");
foreach (var parseHelper in command.GetOptionParseHelpers(_container))
usage.AddOptions(parseHelper);
usage.EndSection();
- output.WriteLine("Usage: git-tfs " + GetCommandUsage(command));
usage.ToText(output, OptStyle.Unix, true);
+
+ //new
+ command.OptionSet.WriteOptionDescriptions(output);
+
return GitTfsExitCodes.Help;
}
View
@@ -3,6 +3,7 @@
using System.ComponentModel;
using System.IO;
using System.Text.RegularExpressions;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -30,6 +31,11 @@ public Init(RemoteOptions remoteOptions, InitOptions initOptions, Globals global
this.initOptions = initOptions;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get
View
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -16,6 +17,11 @@ public class Pull : GitTfsCommand
private readonly Fetch fetch;
private readonly Globals globals;
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(fetch); }
@@ -3,6 +3,7 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -29,6 +30,11 @@ public Rcheckin(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writ
_writer = writer;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(_checkinOptions); }
@@ -129,4 +135,4 @@ private int PerformRCheckin(TfsChangesetInfo parentChangeset)
}
}
}
-}
+}
@@ -3,6 +3,7 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -32,6 +33,11 @@ public Shelve(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer
_writer = writer;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(_checkinOptions); }
@@ -3,6 +3,7 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -38,6 +39,11 @@ public class ShelveList : GitTfsCommand
[Description("Shelveset owner ('all' means all users)")]
public string Owner { get; set; }
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(); }
@@ -5,6 +5,7 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using StructureMap;
@@ -29,6 +30,11 @@ public Unshelve(Globals globals)
[Description("Shelveset owner ('all' means all users)")]
public string Owner { get; set; }
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(); }
@@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Security.Cryptography;
+using NDesk.Options;
using CommandLine.OptParse;
using Sep.Git.Tfs.Core;
using Sep.Git.Tfs.Core.TfsInterop;
@@ -23,6 +24,11 @@ public Verify(Globals globals, TreeVerifier verifier)
_verifier = verifier;
}
+ public OptionSet OptionSet
+ {
+ get { return new OptionSet(); }
+ }
+
public IEnumerable<IOptionResults> ExtraOptions
{
get { return this.MakeNestedOptionResults(); }
View
@@ -174,6 +174,7 @@ public GitTfsCommand ExtractCommand(IList<string> args)
public IList<string> ParseOptions(GitTfsCommand command, IList<string> args)
{
+ args = command.OptionSet.Parse(args);
foreach (var parseHelper in command.GetOptionParseHelpers(_container))
{
var parser = new Parser(parseHelper);
View
@@ -61,6 +61,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\CSharpOptParse\CSharpOptParse.dll</HintPath>
</Reference>
+ <Reference Include="NDesk.Options, Version=0.2.1.0, Culture=neutral">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\lib\NDesk.Options\lib\ndesk-options\NDesk.Options.dll</HintPath>
+ </Reference>
<Reference Include="GitSharp.Core, Version=0.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\GitSharp-0.3\GitSharp.Core.dll</HintPath>
@@ -223,4 +227,4 @@
<PropertyGroup>
<PreBuildEvent>"$(ProjectDir)..\GetCurrentVersion" "$(GitPath)" &gt; "$(ProjectDir)GitVersionInfo"</PreBuildEvent>
</PropertyGroup>
-</Project>
+</Project>
View
@@ -1,12 +1,15 @@
using System.Collections.Generic;
using CommandLine.OptParse;
+using NDesk.Options;
using StructureMap;
namespace Sep.Git.Tfs
{
[PluginFamily]
public interface GitTfsCommand
{
+ OptionSet OptionSet { get; }
+ [System.Obsolete("Use OptionSet instead")]
IEnumerable<IOptionResults> ExtraOptions { get; }
}
}

0 comments on commit 157676c

Please sign in to comment.