using CliFx;
using ZB.MOM.WW.OtOpcUa.Client.CLI;

return await new CliApplicationBuilder()
    .AddCommandsFromThisAssembly()
    .UseTypeActivator(type =>
    {
        // Inject the default factory into commands that derive from CommandBase
        if (type.IsSubclassOf(typeof(CommandBase))) return Activator.CreateInstance(type, CommandBase.DefaultFactory)!;
        return Activator.CreateInstance(type)!;
    })
    .SetExecutableName("otopcua-cli")
    .SetDescription("OtOpcUa CLI - command-line client for the OtOpcUa OPC UA server")
    .Build()
    .RunAsync(args);