Skip to content

Commit f691b10

Browse files
Remove legacy IPC aliases
Drop the pre-merge background-api and automation compatibility layer so the branch exposes only the final IPC argument names, endpoint metadata path, and public verb-based CLI surface. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2c9053a commit f691b10

6 files changed

Lines changed: 46 additions & 159 deletions

File tree

docs/CLI.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ Related environment variables:
5151
- `--source` maps to `--package-source`
5252
- Boolean options use explicit values such as `--enabled true` or `--wait false`.
5353
- `--detach` is shorthand for asynchronous package operations (`--wait false`).
54-
- The internal `--automation ...` mode still exists for compatibility, but the public CLI is the verb-based surface documented here.
5554

5655
## Command reference
5756

src/UniGetUI.Interface.IpcApi/IpcCliCommandRunner.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ public enum IpcCliExitCode
1515

1616
public static class IpcCliCommandRunner
1717
{
18-
public const string LegacyCommandArgument = "--automation";
19-
2018
public static async Task<int> RunAsync(
2119
IReadOnlyList<string> args,
2220
TextWriter output,
@@ -30,7 +28,11 @@ TextWriter error
3028
return (int)IpcCliExitCode.Success;
3129
}
3230

33-
if (parseResult.Status != IpcCliParseStatus.Success || parseResult.EffectiveArgs is null)
31+
if (
32+
parseResult.Status != IpcCliParseStatus.Success
33+
|| parseResult.Command is null
34+
|| parseResult.EffectiveArgs is null
35+
)
3436
{
3537
return await WriteErrorAsync(
3638
output,
@@ -40,8 +42,7 @@ TextWriter error
4042
}
4143

4244
args = parseResult.EffectiveArgs;
43-
int basePos = args.ToList().IndexOf(LegacyCommandArgument);
44-
string subcommand = args[basePos + 1].Trim().ToLowerInvariant();
45+
string subcommand = parseResult.Command.Trim().ToLowerInvariant();
4546

4647
try
4748
{

src/UniGetUI.Interface.IpcApi/IpcCliSyntax.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ internal enum IpcCliParseStatus
1010

1111
internal sealed record IpcCliParseResult(
1212
IpcCliParseStatus Status,
13+
string? Command = null,
1314
string[]? EffectiveArgs = null,
1415
string? Message = null
1516
);
@@ -91,8 +92,8 @@ internal static IpcCliParseResult Parse(IReadOnlyList<string> args)
9192
return new(IpcCliParseStatus.Help);
9293
}
9394

94-
string? legacyCommand = TryMapLegacyCommand(path, out List<string> injectedArgs);
95-
if (legacyCommand is null)
95+
string? command = TryMapCommand(path, out List<string> injectedArgs);
96+
if (command is null)
9697
{
9798
return new(
9899
IpcCliParseStatus.NotIpcCommand,
@@ -109,17 +110,12 @@ internal static IpcCliParseResult Parse(IReadOnlyList<string> args)
109110
}
110111
}
111112

112-
RewriteArgumentAliases(legacyCommand, remainingArgs);
113+
RewriteArgumentAliases(command, remainingArgs);
113114

114115
return new(
115116
IpcCliParseStatus.Success,
116-
[
117-
.. leadingGlobalArgs,
118-
IpcCliCommandRunner.LegacyCommandArgument,
119-
legacyCommand,
120-
.. injectedArgs,
121-
.. remainingArgs,
122-
]
117+
Command: command,
118+
EffectiveArgs: [.. leadingGlobalArgs, .. injectedArgs, .. remainingArgs]
123119
);
124120
}
125121

@@ -189,7 +185,7 @@ private static string NormalizeToken(string token)
189185
};
190186
}
191187

192-
private static string? TryMapLegacyCommand(string[] path, out List<string> injectedArgs)
188+
private static string? TryMapCommand(string[] path, out List<string> injectedArgs)
193189
{
194190
injectedArgs = [];
195191

@@ -297,20 +293,20 @@ private static string NormalizeToken(string token)
297293
}
298294

299295
private static string Inject(
300-
string legacyCommand,
296+
string command,
301297
List<string> injectedArgs,
302298
params string[] args
303299
)
304300
{
305301
injectedArgs.AddRange(args);
306-
return legacyCommand;
302+
return command;
307303
}
308304

309-
private static void RewriteArgumentAliases(string legacyCommand, List<string> args)
305+
private static void RewriteArgumentAliases(string command, List<string> args)
310306
{
311307
for (int i = 0; i < args.Count; i++)
312308
{
313-
args[i] = legacyCommand switch
309+
args[i] = command switch
314310
{
315311
"get-operation" or "get-operation-output" or "wait-operation" or "cancel-operation"
316312
or "retry-operation" or "reorder-operation" or "forget-operation"

src/UniGetUI.Interface.IpcApi/IpcTransport.cs

Lines changed: 8 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,15 @@ string NamedPipeName
2828
public const string TransportArgument = "--ipc-api-transport";
2929
public const string TcpPortArgument = "--ipc-api-port";
3030
public const string NamedPipeArgument = "--ipc-api-pipe-name";
31-
public const string LegacyTransportArgument = "--background-api-transport";
32-
public const string LegacyTcpPortArgument = "--background-api-port";
33-
public const string LegacyNamedPipeArgument = "--background-api-pipe-name";
34-
3531
public const string CliTransportArgument = "--transport";
3632
public const string CliTcpPortArgument = "--tcp-port";
3733
public const string CliNamedPipeArgument = "--pipe-name";
3834

3935
public const string TransportEnvironmentVariable = "UNIGETUI_IPC_API_TRANSPORT";
4036
public const string TcpPortEnvironmentVariable = "UNIGETUI_IPC_API_PORT";
4137
public const string NamedPipeEnvironmentVariable = "UNIGETUI_IPC_API_PIPE_NAME";
42-
public const string LegacyTransportEnvironmentVariable = "UNIGETUI_API_TRANSPORT";
43-
public const string LegacyTcpPortEnvironmentVariable = "UNIGETUI_API_PORT";
44-
public const string LegacyNamedPipeEnvironmentVariable = "UNIGETUI_API_PIPE_NAME";
4538

46-
private const string EndpointMetadataDirectoryName = "BackgroundApiEndpoints";
47-
private const string LegacyEndpointMetadataFileName = "BackgroundApiEndpoint.json";
39+
private const string EndpointMetadataDirectoryName = "IpcApiEndpoints";
4840

4941
public Uri BaseAddress =>
5042
TransportKind == IpcTransportKind.NamedPipe
@@ -72,9 +64,6 @@ string NamedPipeName
7264
public static string EndpointMetadataDirectoryPath =>
7365
Path.Join(CoreData.UniGetUIUserConfigurationDirectory, EndpointMetadataDirectoryName);
7466

75-
private static string LegacyEndpointMetadataPath =>
76-
Path.Join(CoreData.UniGetUIUserConfigurationDirectory, LegacyEndpointMetadataFileName);
77-
7867
public static IpcTransportOptions LoadForServer(IReadOnlyList<string>? args = null)
7968
{
8069
args ??= Environment.GetCommandLineArgs();
@@ -104,7 +93,6 @@ public static IpcTransportOptions LoadForClient(IReadOnlyList<string>? args = nu
10493
public void Persist(string sessionId, string token, string sessionKind, int processId)
10594
{
10695
Directory.CreateDirectory(EndpointMetadataDirectoryPath);
107-
DeleteLegacyPersistedMetadata();
10896

10997
var metadata = new IpcEndpointRegistration
11098
{
@@ -141,8 +129,6 @@ public static void DeletePersistedMetadata(string? sessionId = null)
141129
{
142130
Directory.Delete(EndpointMetadataDirectoryPath, recursive: true);
143131
}
144-
145-
DeleteLegacyPersistedMetadata();
146132
return;
147133
}
148134

@@ -191,48 +177,6 @@ internal static IReadOnlyList<IpcEndpointRegistration> LoadPersistedRegistration
191177
Logger.Warn(ex);
192178
}
193179

194-
try
195-
{
196-
if (File.Exists(LegacyEndpointMetadataPath))
197-
{
198-
var legacyMetadata = JsonSerializer.Deserialize<IpcStatus>(
199-
File.ReadAllText(LegacyEndpointMetadataPath),
200-
new JsonSerializerOptions(SerializationHelpers.DefaultOptions)
201-
{
202-
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
203-
WriteIndented = true,
204-
}
205-
);
206-
207-
if (legacyMetadata is not null)
208-
{
209-
registrations.Add(
210-
new IpcEndpointRegistration
211-
{
212-
SessionId = "legacy",
213-
SessionKind = GuiSessionKind,
214-
Token = string.Empty,
215-
Transport = ParseTransport(
216-
legacyMetadata.Transport,
217-
Default.TransportKind
218-
),
219-
TcpPort = legacyMetadata.TcpPort > 0
220-
? legacyMetadata.TcpPort
221-
: DefaultTcpPort,
222-
NamedPipeName = string.IsNullOrWhiteSpace(legacyMetadata.NamedPipeName)
223-
? DefaultNamedPipeName
224-
: legacyMetadata.NamedPipeName,
225-
}
226-
);
227-
}
228-
}
229-
}
230-
catch (Exception ex)
231-
{
232-
Logger.Warn("Could not load legacy IPC API endpoint metadata");
233-
Logger.Warn(ex);
234-
}
235-
236180
return registrations;
237181
}
238182

@@ -270,21 +214,9 @@ internal static bool HasExplicitClientOverride(IReadOnlyList<string> args)
270214
|| args.Contains(TransportArgument)
271215
|| args.Contains(TcpPortArgument)
272216
|| args.Contains(NamedPipeArgument)
273-
|| args.Contains(LegacyTransportArgument)
274-
|| args.Contains(LegacyTcpPortArgument)
275-
|| args.Contains(LegacyNamedPipeArgument)
276217
|| !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(TransportEnvironmentVariable))
277218
|| !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(TcpPortEnvironmentVariable))
278-
|| !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(NamedPipeEnvironmentVariable))
279-
|| !string.IsNullOrWhiteSpace(
280-
Environment.GetEnvironmentVariable(LegacyTransportEnvironmentVariable)
281-
)
282-
|| !string.IsNullOrWhiteSpace(
283-
Environment.GetEnvironmentVariable(LegacyTcpPortEnvironmentVariable)
284-
)
285-
|| !string.IsNullOrWhiteSpace(
286-
Environment.GetEnvironmentVariable(LegacyNamedPipeEnvironmentVariable)
287-
);
219+
|| !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(NamedPipeEnvironmentVariable));
288220
}
289221

290222
private static string GetEndpointMetadataPath(string sessionId)
@@ -309,29 +241,26 @@ IpcTransportOptions fallback
309241
string? transportValue = GetArgumentValue(
310242
args,
311243
includeCliAliases
312-
? [CliTransportArgument, TransportArgument, LegacyTransportArgument]
313-
: [TransportArgument, LegacyTransportArgument]
244+
? [CliTransportArgument, TransportArgument]
245+
: [TransportArgument]
314246
);
315247
transportValue ??= Environment.GetEnvironmentVariable(TransportEnvironmentVariable);
316-
transportValue ??= Environment.GetEnvironmentVariable(LegacyTransportEnvironmentVariable);
317248

318249
string? portValue = GetArgumentValue(
319250
args,
320251
includeCliAliases
321-
? [CliTcpPortArgument, TcpPortArgument, LegacyTcpPortArgument]
322-
: [TcpPortArgument, LegacyTcpPortArgument]
252+
? [CliTcpPortArgument, TcpPortArgument]
253+
: [TcpPortArgument]
323254
);
324255
portValue ??= Environment.GetEnvironmentVariable(TcpPortEnvironmentVariable);
325-
portValue ??= Environment.GetEnvironmentVariable(LegacyTcpPortEnvironmentVariable);
326256

327257
string? pipeValue = GetArgumentValue(
328258
args,
329259
includeCliAliases
330-
? [CliNamedPipeArgument, NamedPipeArgument, LegacyNamedPipeArgument]
331-
: [NamedPipeArgument, LegacyNamedPipeArgument]
260+
? [CliNamedPipeArgument, NamedPipeArgument]
261+
: [NamedPipeArgument]
332262
);
333263
pipeValue ??= Environment.GetEnvironmentVariable(NamedPipeEnvironmentVariable);
334-
pipeValue ??= Environment.GetEnvironmentVariable(LegacyNamedPipeEnvironmentVariable);
335264

336265
var transport = ParseTransport(transportValue, fallback.TransportKind);
337266
int tcpPort = ParseTcpPort(portValue, fallback.TcpPort);
@@ -340,14 +269,6 @@ IpcTransportOptions fallback
340269
return new IpcTransportOptions(transport, tcpPort, pipeName);
341270
}
342271

343-
private static void DeleteLegacyPersistedMetadata()
344-
{
345-
if (File.Exists(LegacyEndpointMetadataPath))
346-
{
347-
File.Delete(LegacyEndpointMetadataPath);
348-
}
349-
}
350-
351272
private static IpcTransportKind ParseTransport(
352273
string? value,
353274
IpcTransportKind fallback

0 commit comments

Comments
 (0)