Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down Expand Up @@ -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
```
Expand Down
29 changes: 28 additions & 1 deletion src/ucll.tests/ProgramTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -25,4 +52,4 @@ private static string FindProjectVersion(string projectFile)

return match.Groups[1].Value;
}
}
}
14 changes: 13 additions & 1 deletion src/ucll/AppConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OpenCommand>("open")
.WithDescription("Open Unity Editor for a project search path or via recent projects prompt")
Expand All @@ -28,6 +29,17 @@ public static void Build(IConfigurator config)
.WithExample("open", "searchPath", "--only-code-editor")
.WithExample("open", "searchPath", "--", "-batchmode", "-quit");

config.AddCommand<OpenCommand>("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<CreateCommand>("create")
.WithDescription("Create a new Unity project")
.WithExample("create", "path/to/new/project")
Expand Down Expand Up @@ -119,4 +131,4 @@ public static void Build(IConfigurator config)
.WithExample("completion")
.WithExample("completion", "zsh");
}
}
}
5 changes: 3 additions & 2 deletions src/ucll/Commands/Completion/CompletionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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]' \
Expand Down Expand Up @@ -123,4 +124,4 @@ private static string GenerateZshCompletion()
_ucll
""";
}
}
}