Remove code for handling single hyphen arguments
and return exit code 1 when argument parsing fails
This commit is contained in:
parent
75b7fea024
commit
b30ae1a949
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -6,7 +7,6 @@ using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
|
@ -59,20 +59,15 @@ namespace Jellyfin.Server
|
||||||
/// <returns><see cref="Task" />.</returns>
|
/// <returns><see cref="Task" />.</returns>
|
||||||
public static Task Main(string[] args)
|
public static Task Main(string[] args)
|
||||||
{
|
{
|
||||||
// For backwards compatibility.
|
static Task ErrorParsingArguments(IEnumerable<Error> errors)
|
||||||
// Modify any input arguments now which start with single-hyphen to POSIX standard
|
|
||||||
// double-hyphen to allow parsing by CommandLineParser package.
|
|
||||||
const string Pattern = @"^(-[^-\s]{2})"; // Match -xx, not -x, not --xx, not xx
|
|
||||||
const string Substitution = @"-$1"; // Prepend with additional single-hyphen
|
|
||||||
var regex = new Regex(Pattern);
|
|
||||||
for (var i = 0; i < args.Length; i++)
|
|
||||||
{
|
{
|
||||||
args[i] = regex.Replace(args[i], Substitution);
|
Environment.ExitCode = 1;
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the command line arguments and either start the app or exit indicating error
|
// Parse the command line arguments and either start the app or exit indicating error
|
||||||
return Parser.Default.ParseArguments<StartupOptions>(args)
|
return Parser.Default.ParseArguments<StartupOptions>(args)
|
||||||
.MapResult(StartApp, _ => Task.CompletedTask);
|
.MapResult(StartApp, ErrorParsingArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user