Skip to content

Commit 397f102

Browse files
authored
Bugfix/fix cli build process failing when flag args are duplicated (#166)
* Ignore duplicated CLI args if value is the same * Fix missing using
1 parent d00858c commit 397f102

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

Assets/Plugins/StreamChat/Core/StreamChatClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
using StreamChat.Libs.Serialization;
2828
using StreamChat.Libs.Time;
2929
using StreamChat.Libs.Websockets;
30-
using StreamChat.Core.LowLevelClient.Requests;
3130
using StreamChat.Libs.Utils;
31+
#if STREAM_TESTS_ENABLED
32+
using System.Text;
33+
#endif
3234

3335
namespace StreamChat.Core
3436
{

Assets/Plugins/StreamChat/EditorTools/CommandLineParsers/BuildSettingsCommandLineParser.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ protected override (BuildSettings buildSettings, AuthCredentials authCredentials
5858

5959
return (new BuildSettings(buildTargetGroup, apiCompatibilityLevel, scriptingImplementation, targetPath),
6060
testAuthDataSet.GetAdminData(forceIndex: optionalTestDataIndex));
61-
62-
6361
}
6462

6563
public TestAuthDataSet ParseTestAuthDataSetArg(IDictionary<string, string> args, out int? forceDataSetIndex)

Assets/Plugins/StreamChat/EditorTools/CommandLineParsers/CommandLineParserBase.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using UnityEngine;
34

45
namespace StreamChat.EditorTools.CommandLineParsers
56
{
@@ -22,7 +23,19 @@ public IDictionary<string, string> GetParsedCommandLineArguments()
2223
protected abstract TResult Parse(IDictionary<string, string> args);
2324

2425
protected void ParseCommandLineArguments(string[] args, IDictionary<string, string> result)
25-
=> ParseCommandLineArguments(args, _ => result.Add(_.Key, _.Value));
26+
=> ParseCommandLineArguments(args, _ =>
27+
{
28+
if (result.ContainsKey(_.Key) && result[_.Key] == _.Value)
29+
{
30+
return;
31+
}
32+
if (result.ContainsKey(_.Key))
33+
{
34+
Debug.LogError(
35+
$"Duplicated key {_.Key} with value given: {_.Value} and already stored: {result[_.Key]}. Values equal: {result[_.Key] == _.Value}");
36+
}
37+
result.Add(_.Key, _.Value);
38+
});
2639

2740
protected void ParseCommandLineArguments(string[] args, Action<(string Key, string Value)> onArgumentParsed)
2841
{
@@ -31,7 +44,7 @@ protected void ParseCommandLineArguments(string[] args, Action<(string Key, stri
3144
if (args[i].StartsWith("-"))
3245
{
3346
var key = args[i];
34-
var value = i < args.Length - 1 ? args[i + 1] : "";
47+
var value = (i < args.Length - 1 && !args[i + 1].StartsWith("-")) ? args[i + 1] : null;
3548

3649
onArgumentParsed?.Invoke((key, value));
3750
}

0 commit comments

Comments
 (0)