Files
git-tfs/GitTfs/Commands/InitOptions.cs
T
Pat Thoyts 7cab876287 Added option to set core.autocrlf for init and clone.
This implements the suggestion in issue #220 and leaves the default as
false but permits true or auto but not any other values.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
2012-11-07 16:18:05 +00:00

44 lines
1.4 KiB
C#

using System;
using System.ComponentModel;
using NDesk.Options;
using Sep.Git.Tfs.Util;
namespace Sep.Git.Tfs.Commands
{
[StructureMapSingleton]
public class InitOptions
{
private const string default_autocrlf = "false";
public InitOptions() { GitInitAutoCrlf = default_autocrlf; }
public OptionSet OptionSet
{
get
{
return new OptionSet
{
{ "template=", "Passed to git-init",
v => GitInitTemplate = v },
{ "shared:", "Passed to git-init",
v => GitInitShared = v == null ? (object)true : (object)v },
{ "autocrlf=", "Normalize line endings (default: " + default_autocrlf + ")",
v => GitInitAutoCrlf = (v == "") ? default_autocrlf : ValidateCrlfValue(v) },
};
}
}
string ValidateCrlfValue(string v)
{
string[] valid = { "false", "true", "auto" };
if (!Array.Exists(valid, s => v == s))
throw new OptionException("error: autocrlf value must be one of true, false or auto", "autocrlf");
return v;
}
public string GitInitTemplate { get; set; }
public object GitInitShared { get; set; }
public string GitInitAutoCrlf { get; set; }
}
}