Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass through the CommandLineApplication return code #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/SharpGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

using Confuser.Core;
using Confuser.Core.Project;
using YamlDotNet.Serialization;

using YamlDotNet.Serialization;
namespace SharpGen
{
class SharpGen
{
static void Main(string[] args)
static int Main(string[] args)
{
CommandLineApplication app = new CommandLineApplication();
app.HelpOption("-? | -h | --help");
Expand Down Expand Up @@ -84,7 +84,7 @@ static void Main(string[] args)
).Accepts(v => v.ExistingFile());

app.OnExecute(() =>
{
{
Compiler.CompilationRequest request = new Compiler.CompilationRequest();
// Compilation options
if (!SetRequestDirectories(ref request))
Expand Down Expand Up @@ -192,7 +192,7 @@ static void Main(string[] args)
}
return 0;
});
app.Execute(args);
return app.Execute(args);
}

private static bool SetRequestDirectories(ref Compiler.CompilationRequest request)
Expand All @@ -201,16 +201,16 @@ private static bool SetRequestDirectories(ref Compiler.CompilationRequest reques
request.ReferenceDirectory = Common.SharpGenReferencesDirectory;
request.ResourceDirectory = Common.SharpGenResourcesDirectory;
return true;
}

}
private static bool SetRequestDotNetVersion(CommandOption<Compiler.DotNetVersion> DotNetVersionOption, ref Compiler.CompilationRequest request)
{
{
request.TargetDotNetVersion = DotNetVersionOption.HasValue() ? DotNetVersionOption.ParsedValue : Compiler.DotNetVersion.Net35;
return true;
}
return true;
}

private static bool SetRequestOutputKind(CommandOption OutputKindOption, CommandOption OutputFileOption, ref Compiler.CompilationRequest request)
{
{
if (OutputKindOption.HasValue())
{
if (OutputKindOption.Value().Contains("console", StringComparison.OrdinalIgnoreCase) || OutputKindOption.Value().Contains("exe", StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -272,16 +272,16 @@ private static bool SetRequestOptimization(CommandOption NoOptimizationOption, r
{
request.Optimize = !NoOptimizationOption.HasValue();
return true;
}

}
private static bool SetRequestAssemblyName(CommandOption AssemblyNameOption, ref Compiler.CompilationRequest request)
{
if (AssemblyNameOption.HasValue()) { request.AssemblyName = AssemblyNameOption.Value(); }
return true;
}

private static bool SetRequestReferences(ref Compiler.CompilationRequest request)
{
{
using (TextReader reader = File.OpenText(Common.SharpGenReferencesConfig))
{
var deserializer = new DeserializerBuilder().Build();
Expand All @@ -299,7 +299,7 @@ private static bool SetRequestEmbeddedResources(ref Compiler.CompilationRequest
}
return true;
}

private static bool SetRequestSource(CommandOption SourceFileOption, CommandOption ClassNameOption, List<string> RemainingArguments, ref Compiler.CompilationRequest request)
{
string className = RandomString();
Expand Down Expand Up @@ -362,7 +362,7 @@ public ValidationResult GetValidationResult(CommandOption option, ValidationCont
}

return ValidationResult.Success;
}
}
}

private class MustBeDotNetVersionValidator : IOptionValidator
Expand Down Expand Up @@ -421,7 +421,7 @@ private static string RandomString()
return alphachars[random.Next(alphachars.Length)] + new string(Enumerable.Repeat(chars, random.Next(10, 30)).Select(s => s[random.Next(s.Length)]).ToArray());
}

private static string WrapperFunctionFormat =
private static string WrapperFunctionFormat =
@"using System;
using System.IO;
using System.Text;
Expand Down