using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Reflection; namespace Unity.Pipeline.Commands { /// /// Information about a discovered CLI command. /// Contains metadata needed for command execution and CLI help generation. /// public class CommandInfo { /// /// Unique name of the command for CLI execution. /// public string Name { get; } /// /// Human-readable description of the command. /// public string Description { get; } /// /// Whether this command requires Unity main thread execution. /// public bool MainThreadRequired { get; } /// /// Whether this command is part of the runtime (Player) command surface only. /// Editor servers hide runtime-only commands from their command listing. /// public bool RuntimeOnly { get; } /// /// Method that implements this command. /// public MethodInfo Method { get; } // TODO Maybe look at generating a dynamic Delegate to increase performance of the command call. /// /// Parameters that this command accepts. /// public IReadOnlyList Parameters { get; } /// /// Create command information from discovery. /// public CommandInfo(string name, string description, bool mainThreadRequired, MethodInfo method, IReadOnlyList parameters, bool runtimeOnly = false) { Name = name ?? throw new ArgumentNullException(nameof(name)); Description = description ?? throw new ArgumentNullException(nameof(description)); Method = method ?? throw new ArgumentNullException(nameof(method)); Parameters = parameters ?? throw new ArgumentNullException(nameof(parameters)); MainThreadRequired = mainThreadRequired; RuntimeOnly = runtimeOnly; } public override string ToString() { return $"{Name} MainThreadRequired:{MainThreadRequired} Parameters:{Parameters.Count}"; } } }