diff --git a/README.md b/README.md index 1b59fc6..b49e770 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ with CI/CD pipelines. | Name | Description | |--------------------------------|-----------------------------------------------------------------------------| | `open [path]` | Opens the Unity editor by searching for a project within path. | +| `run [path]` | Alias for `open`, useful for headless/batchmode scripts. | | `open` | Shows a selection prompt of recent or favorite projects from the Unity Hub. | | `install [version]` | Installs the Editor by version, fetching the revision, if necessary. | | `install-missing` | Installs all Unity versions used by projects but not installed. | @@ -251,6 +252,13 @@ Forward additional arguments to Unity Hub/Editor by separating them with a `--`: ucll open path/to/project -- -batchmode -quit ``` +For build pipelines or other headless invocations, `run` is an alias for +`open` with the same options and forwarded Unity arguments: + +```shell +ucll run path/to/project -- -batchmode -quit +``` + ```shell ucll install 2022.3.10f1 -- --module webgl ``` diff --git a/src/ucll.tests/ProgramTests.cs b/src/ucll.tests/ProgramTests.cs index 10f9ae3..075da92 100644 --- a/src/ucll.tests/ProgramTests.cs +++ b/src/ucll.tests/ProgramTests.cs @@ -15,6 +15,33 @@ public void Version() Assert.Equal(expectedVersion, result.Output); } + [Fact] + public void RunAliasIsListedInHelp() + { + var app = new CommandAppTester(); + app.Configure(AppConfiguration.Build); + + var result = app.Run("--help"); + + Assert.Equal(0, result.ExitCode); + Assert.Contains("run", result.Output); + Assert.Contains("Open Unity Editor", result.Output); + } + + [Fact] + public void RunAliasUsesOpenCommandOptions() + { + var app = new CommandAppTester(); + app.Configure(AppConfiguration.Build); + + var result = app.Run("run", "--help"); + + Assert.Equal(0, result.ExitCode); + Assert.Contains("--code-editor", result.Output); + Assert.Contains("--only-code-editor", result.Output); + Assert.Contains("--no-hub-args", result.Output); + } + private static string FindProjectVersion(string projectFile) { string projectContent = File.ReadAllText(projectFile); @@ -25,4 +52,4 @@ private static string FindProjectVersion(string projectFile) return match.Groups[1].Value; } -} \ No newline at end of file +} diff --git a/src/ucll/AppConfiguration.cs b/src/ucll/AppConfiguration.cs index 7a01a0d..3b0a7a7 100644 --- a/src/ucll/AppConfiguration.cs +++ b/src/ucll/AppConfiguration.cs @@ -16,6 +16,7 @@ public static void Build(IConfigurator config) config.AddExample("open", "searchPath", "--code-editor"); config.AddExample("open", "searchPath", "--only-code-editor"); config.AddExample("open", "searchPath", "--", "-batchmode", "-quit"); + config.AddExample("run", "searchPath", "--", "-batchmode", "-quit"); config.AddCommand("open") .WithDescription("Open Unity Editor for a project search path or via recent projects prompt") @@ -28,6 +29,17 @@ public static void Build(IConfigurator config) .WithExample("open", "searchPath", "--only-code-editor") .WithExample("open", "searchPath", "--", "-batchmode", "-quit"); + config.AddCommand("run") + .WithDescription("Run Unity Editor for a project search path or via recent projects prompt") + .WithExample("run") + .WithExample("run", "--favorite") + .WithExample("run", ".") + .WithExample("run", "searchPath", "--no-hub-args", "--", "-batchmode", "-quit") + .WithExample("run", "searchPath", "--no-hub-args") + .WithExample("run", "searchPath", "--code-editor") + .WithExample("run", "searchPath", "--only-code-editor") + .WithExample("run", "searchPath", "--", "-batchmode", "-quit"); + config.AddCommand("create") .WithDescription("Create a new Unity project") .WithExample("create", "path/to/new/project") @@ -119,4 +131,4 @@ public static void Build(IConfigurator config) .WithExample("completion") .WithExample("completion", "zsh"); } -} \ No newline at end of file +} diff --git a/src/ucll/Commands/Completion/CompletionCommand.cs b/src/ucll/Commands/Completion/CompletionCommand.cs index 07c4775..59d4444 100644 --- a/src/ucll/Commands/Completion/CompletionCommand.cs +++ b/src/ucll/Commands/Completion/CompletionCommand.cs @@ -21,6 +21,7 @@ private static string GenerateZshCompletion() local -a commands commands=( 'open:Open Unity Editor for a project search path or via recent projects prompt' + 'run:Run Unity Editor for a project search path or via recent projects prompt' 'create:Create a new Unity project' 'project-path:Get Unity project root directory from search path or via recent projects prompt' 'editor-revision:Get revision for Unity version' @@ -47,7 +48,7 @@ private static string GenerateZshCompletion() ;; args) case $words[1] in - open) + open|run) _arguments \ '(-f --favorite --favorites)'{-f,--favorite,--favorites}'[Use favorite projects only]' \ '(-c --code-editor)'{-c,--code-editor}'[Open the solution file in the default code editor]' \ @@ -123,4 +124,4 @@ private static string GenerateZshCompletion() _ucll """; } -} \ No newline at end of file +}