From 20920c262d8bbf9363f5662113db7fb988e90f39 Mon Sep 17 00:00:00 2001 From: q4kK Date: Tue, 9 Apr 2024 13:09:27 -0500 Subject: [PATCH] Feat: add no-interactive flag for `upgrade.php` Having a no-interactive flag is useful because attempting to automate snipe-it upgrades is currently extremely janky. You have to either: a) read the prompts and pass in the input (the "correct" way) b) pipe in input, e.g. `yes` and hope no new prompts are added. With the `no-interactive` flag, this can be fixed by both allowing new prompts to be added without conflict to user prompts, but also allowing automated upgrades (you could choose to crash, or assign defaults). --- upgrade.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/upgrade.php b/upgrade.php index 2fd1c45426..0ac33856f3 100644 --- a/upgrade.php +++ b/upgrade.php @@ -19,6 +19,7 @@ $app_environment = 'develop'; $skip_php_checks = false; $branch = 'master'; $branch_override = false; +$no_interactive = false; // Check for branch or other overrides if ($argc > 1){ @@ -32,6 +33,9 @@ if ($argc > 1){ $branch = $argv[$arg]; $branch_override = true; break; + case '--no-interactive': + $no_interactive = true; + break; default: // for legacy support from before we started using --branch $branch = $argv[$arg]; $branch_override = true; @@ -81,7 +85,13 @@ if($upgrade_requirements){ echo "Found PHP requirements, will check for PHP > $php_min_works and < $php_max_wontwork\n"; } // done fetching requirements -$yesno = readline("\nProceed with upgrade? [Y/n]: "); + +if (!$no_interactive) { + $yesno = readline("\nProceed with upgrade? [Y/n]: "); +} else { + $yesno = "yes"; +} + if ($yesno == "yes" || $yesno == "YES" ||$yesno == "y" ||$yesno == "Y"){ # don't do anything } else {