This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
121 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024.05.02.00.05 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,83 @@ | ||
using MinecraftLaunch.Components.Fetcher; | ||
using MinecraftLaunch.Components.Analyzer; | ||
using MinecraftLaunch.Components.Fetcher; | ||
using MinecraftLaunch.Components.Installer; | ||
using MinecraftLaunch.Components.Resolver; | ||
|
||
public class Program | ||
{ | ||
public static async Task Main() | ||
public static List<Tuple<string, List<string>>> ParseCommandLine(string commandLine) | ||
{ | ||
using (var client = new HttpClient()) | ||
var parameters = new List<Tuple<string, List<string>>>(); | ||
var currentMethod = string.Empty; | ||
var currentArgs = new List<string>(); | ||
var isInQuotes = false; | ||
var argBuilder = new System.Text.StringBuilder(); | ||
|
||
foreach (var c in commandLine) | ||
{ | ||
try | ||
if (c == '"') | ||
{ | ||
isInQuotes = !isInQuotes; // Toggle the quotes state | ||
continue; // Skip the quote character | ||
} | ||
|
||
if (char.IsWhiteSpace(c) && !isInQuotes) | ||
{ | ||
var response = await client.GetAsync("https://daiyu.fun/page/YmclComments/"); | ||
response.EnsureSuccessStatusCode(); | ||
string htmlContent = await response.Content.ReadAsStringAsync(); // 读取HTML内容 | ||
Console.WriteLine(htmlContent); // 输出HTML内容到控制台 | ||
// If we're not in quotes and encounter a whitespace, it might be the end of a method or argument | ||
if (!string.IsNullOrEmpty(currentMethod)) | ||
{ | ||
// If we have a method name, add the current args list to the parameters | ||
parameters.Add(Tuple.Create(currentMethod, currentArgs)); | ||
// Reset for the next method/argument | ||
currentMethod = string.Empty; | ||
currentArgs = new List<string>(); | ||
} | ||
else if (argBuilder.Length > 0) | ||
{ | ||
// If we don't have a method name but have built an argument, add it to the current args list | ||
currentArgs.Add(argBuilder.ToString()); | ||
argBuilder.Clear(); | ||
} | ||
// Otherwise, do nothing (it's just whitespace) | ||
} | ||
catch (HttpRequestException e) | ||
else | ||
{ | ||
Console.WriteLine("\nException Caught!"); | ||
Console.WriteLine("Message :{0} ", e.Message); | ||
// If we're here, we're either building a method name or an argument | ||
if (string.IsNullOrEmpty(currentMethod) && !char.IsWhiteSpace(c)) | ||
{ | ||
// Start of a new method name | ||
currentMethod = c.ToString(); | ||
} | ||
else | ||
{ | ||
// Building an argument or continuing a method name | ||
argBuilder.Append(c); | ||
} | ||
} | ||
} | ||
|
||
Console.ReadKey(); | ||
// Add the last method and its arguments (if any) | ||
if (!string.IsNullOrEmpty(currentMethod)) | ||
{ | ||
parameters.Add(Tuple.Create(currentMethod, currentArgs)); | ||
} | ||
else if (argBuilder.Length > 0) | ||
{ | ||
// If there's a leftover argument without a method name, it's an error or the input is malformed | ||
// You can decide how to handle this case | ||
throw new ArgumentException("Malformed command line: argument without a method name."); | ||
} | ||
|
||
return parameters; | ||
} | ||
public static async Task Main() | ||
{ | ||
var commandLine = "--launch '1.20.1-Fabric 0.15.10' --close create 'some value' another_value --ey"; | ||
var parsedParameters = ParseCommandLine(commandLine); | ||
|
||
foreach (var parameter in parsedParameters) | ||
{ | ||
Console.WriteLine($"Method: {parameter.Item1}, Args: {string.Join(", ", parameter.Item2)}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters