Skip to content

Commit aec2514

Browse files
Add --yes option to Install and Uninstall commands to skip confirmation prompts
1 parent b21cb8a commit aec2514

5 files changed

Lines changed: 10 additions & 2 deletions

File tree

TestPlan.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ This document contains test cases that need to be verified before releasing a ne
115115
|----------------------------------|-----------------------------------------|----------------------------------------------------------------|:-----:|
116116
| Install missing versions | `unity install-missing` | Shows a prompt before installing | [ ] |
117117
| Install missing versions | `unity install-missing` | Installs all Unity versions used by projects but not installed | [ ] |
118+
| Install missing with --yes | `unity install-missing --yes` | Skips confirmation prompt and installs missing versions | [ ] |
118119
| Install missing with dry-run | `unity install-missing --dry-run` | Shows what would be installed without installing | [ ] |
119120
| Install missing with Hub modules | `unity install-missing -- --module ios` | Installs missing versions with additional Hub arguments | [ ] |
120121
| No missing versions | `unity install-missing` (all installed) | Shows message that no versions need to be installed | [ ] |
@@ -126,6 +127,7 @@ This document contains test cases that need to be verified before releasing a ne
126127
|-------------------------------|----------------------------------------|--------------------------------------------------------|:-----:|
127128
| Uninstall unused versions | `unity uninstall-unused` | Shows a prompt before uninstalling | [ ] |
128129
| Uninstall unused versions | `unity uninstall-unused` | Uninstalls all Unity versions not used by any projects | [ ] |
130+
| Uninstall unused with --yes | `unity uninstall-unused --yes` | Skips confirmation prompt and uninstalls unused versions | [ ] |
129131
| Uninstall unused with dry-run | `unity uninstall-unused --dry-run` | Shows what would be uninstalled without uninstalling | [ ] |
130132
| No unused versions | `unity uninstall-unused` (all in use) | Shows message that no versions can be uninstalled | [ ] |
131133
| All versions unused | `unity uninstall-unused` (none in use) | Uninstalls all installed versions | [ ] |

src/ucll/Commands/InstallMissing/InstallMissingCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected override int ExecuteImpl(MutatingSettings settings)
2222

2323
AnsiConsole.WriteLine();
2424

25-
bool shouldInstall = AnsiConsole.Confirm(
25+
bool shouldInstall = settings.Yes || AnsiConsole.Confirm(
2626
"Do you want to install these versions?",
2727
defaultValue: false);
2828

src/ucll/Commands/UninstallUnused/UninstallUnusedCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected override int ExecuteImpl(MutatingSettings settings)
4242

4343
AnsiConsole.WriteLine();
4444

45-
bool shouldUninstall = AnsiConsole.Confirm(
45+
bool shouldUninstall = settings.Yes || AnsiConsole.Confirm(
4646
"Do you want to uninstall these versions?",
4747
defaultValue: false);
4848

src/ucll/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@
8383
config.AddCommand<InstallMissingCommand>("install-missing")
8484
.WithDescription("Install all Unity versions that are used by projects but not currently installed")
8585
.WithExample("install-missing")
86+
.WithExample("install-missing", "--yes")
8687
.WithExample("install-missing", "--dry-run")
8788
.WithExample("install-missing", "--", "--module", "ios");
8889

8990
config.AddCommand<UninstallUnusedCommand>("uninstall-unused")
9091
.WithDescription("Uninstall all Unity versions that are not used by any projects")
9192
.WithExample("uninstall-unused")
93+
.WithExample("uninstall-unused", "--yes")
9294
.WithExample("uninstall-unused", "--dry-run");
9395

9496
config.AddCommand<UpmGitUrlCommand>("upm-git-url")

src/ucll/Shared/MutatingSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ internal class MutatingSettings : CommandSettings
66
[Description("Show what would be executed without actually running mutating commands.")]
77
public bool DryRun { get; init; }
88

9+
[CommandOption("-y|--yes")]
10+
[Description("Skip interactive confirmation prompts and assume yes.")]
11+
public bool Yes { get; init; }
12+
913
public IProcessRunner MutatingProcess => DryRun ? DryRunProcessRunner.DryRun : ProcessRunner.Default;
1014
}

0 commit comments

Comments
 (0)