Skip to content

Commit

Permalink
Better commandline handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hozuki committed Oct 17, 2018
1 parent fdfed37 commit 4b42a38
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Apps/Acb2Wavs/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace DereTore.Apps.BatchDecodeFromAcb {
public sealed class Options {

[Value(0)]
[Value(0, HelpText = "Input file name", Required = true)]
public string InputFileName { get; set; } = string.Empty;

[Option('o', "out", HelpText = "Output file name", Required = false)]
Expand Down
2 changes: 1 addition & 1 deletion Apps/Acb2Wavs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static int ParseOptions(string[] args, out Options options) {
}

if (!succeeded) {
var helpText = CommandLine.Text.HelpText.AutoBuild(parsedResult);
var helpText = CommandLine.Text.HelpText.AutoBuild(parsedResult, null, null);

helpText.AddPreOptionsLine(" ");
helpText.AddPreOptionsLine("Usage: acb2wavs <input ACB> [options]");
Expand Down
2 changes: 1 addition & 1 deletion Apps/Hca2Wav/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace DereTore.Apps.Hca2Wav {
public sealed class Options {

[Value(0)]
[Value(0, HelpText = "Input file name", Required = true)]
public string InputFileName { get; set; } = string.Empty;

[Option('o', "out", HelpText = "Output file name", Required = false)]
Expand Down
2 changes: 1 addition & 1 deletion Apps/Hca2Wav/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static int Main(string[] args) {
}

if (!succeeded) {
var helpText = CommandLine.Text.HelpText.AutoBuild(parsedResult);
var helpText = CommandLine.Text.HelpText.AutoBuild(parsedResult, null, null);
helpText.AddPreOptionsLine(" ");
helpText.AddPreOptionsLine("Usage: hca2wav <input HCA> [options]");
Console.Error.WriteLine(helpText);
Expand Down
6 changes: 5 additions & 1 deletion Apps/JacketCreator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ internal static class Program {
private static int Main(string[] args) {
const int defaultReturnCodeFail = -1;

var parsedResult = Parser.Default.ParseArguments<Options>(args);
var parser = new Parser(settings => {
settings.IgnoreUnknownArguments = true;
});

var parsedResult = parser.ParseArguments<Options>(args);
var isOptionsValid = parsedResult.Tag == ParserResultType.Parsed;

if (!isOptionsValid) {
Expand Down

0 comments on commit 4b42a38

Please sign in to comment.