diff --git a/CHANGELOG.md b/CHANGELOG.md index 41bd527b..81803f20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to Phive are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. +## [Unreleased] + +### Added +* Added `--trust-gpg-keys` option to the `update` command to silently import GPG keys when required + ## [0.16.0] - 2025-04-10 __Please note__: Version 0.16.x requires PHP 8.0 or later. diff --git a/src/commands/help/help.md b/src/commands/help/help.md index 0748fc43..bc6783e8 100644 --- a/src/commands/help/help.md +++ b/src/commands/help/help.md @@ -67,13 +67,15 @@ _-s, --status_ Show the status of all migrations -**update [--prefer-offline] [ ...]** +**update [--prefer-offline] [--trust-gpg-keys] [ ...]** Update PHARs configured in the project's phive.xml to the newest applicable version. - _--prefer-offline_ Try to use local PHARs first, only connect to remote repositories - if no local PHAR satisfies the given version constraint. + _--prefer-offline_ Try to use local PHARs first, only connect to remote repositories + if no local PHAR satisfies the given version constraint. + _--trust-gpg-keys_ Silently import these keys when required (40-digit fingerprint + or 16-digit long key ID, optionally with the `0x` prefix, separated by comma) - _alias_ If one or more aliases are provided, only those will be updated + _alias_ If one or more aliases are provided, only those will be updated **update-repository-list** Update the alias list of known PHAR distributed applications and libraries diff --git a/src/commands/update/UpdateContext.php b/src/commands/update/UpdateContext.php index b44178a9..6fa5a94d 100644 --- a/src/commands/update/UpdateContext.php +++ b/src/commands/update/UpdateContext.php @@ -10,13 +10,19 @@ */ namespace PharIo\Phive; +use function in_array; use PharIo\Phive\Cli\GeneralContext; class UpdateContext extends GeneralContext { + public function requiresValue(string $option): bool { + return in_array($option, ['trust-gpg-keys'], true); + } + protected function getKnownOptions(): array { return [ 'force-accept-unsigned' => false, 'prefer-offline' => false, + 'trust-gpg-keys' => false, 'global' => 'g' ]; }