1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-17 19:21:04 +00:00

Merge pull request #319860 from superherointj/update-script-skip-prompt

maintainers/scripts/update: support skipping prompts
This commit is contained in:
❄️ 2024-07-12 10:55:40 -03:00 committed by GitHub
commit 61ff097de5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View file

@ -13,6 +13,7 @@
, include-overlays ? false
, keep-going ? null
, commit ? null
, skip-prompt ? null
}:
let
@ -184,6 +185,10 @@ let
that support it by adding
--argstr commit true
to skip prompt:
--argstr skip-prompt true
'';
/* Transform a matched package into an object for update.py.
@ -204,7 +209,8 @@ let
optionalArgs =
lib.optional (max-workers != null) "--max-workers=${max-workers}"
++ lib.optional (keep-going == "true") "--keep-going"
++ lib.optional (commit == "true") "--commit";
++ lib.optional (commit == "true") "--commit"
++ lib.optional (skip-prompt == "true") "--skip-prompt";
args = [ packagesJson ] ++ optionalArgs;

View file

@ -207,7 +207,7 @@ async def start_updates(max_workers: int, keep_going: bool, commit: bool, packag
eprint(e)
sys.exit(1)
def main(max_workers: int, keep_going: bool, commit: bool, packages_path: str) -> None:
def main(max_workers: int, keep_going: bool, commit: bool, packages_path: str, skip_prompt: bool) -> None:
with open(packages_path) as f:
packages = json.load(f)
@ -217,7 +217,8 @@ def main(max_workers: int, keep_going: bool, commit: bool, packages_path: str) -
eprint(f" - {package['name']}")
eprint()
confirm = input('Press Enter key to continue...')
confirm = '' if skip_prompt else input('Press Enter key to continue...')
if confirm == '':
eprint()
eprint('Running update for:')
@ -236,12 +237,13 @@ parser.add_argument('--max-workers', '-j', dest='max_workers', type=int, help='N
parser.add_argument('--keep-going', '-k', dest='keep_going', action='store_true', help='Do not stop after first failure')
parser.add_argument('--commit', '-c', dest='commit', action='store_true', help='Commit the changes')
parser.add_argument('packages', help='JSON file containing the list of package names and their update scripts')
parser.add_argument('--skip-prompt', '-s', dest='skip_prompt', action='store_true', help='Do not stop for prompts')
if __name__ == '__main__':
args = parser.parse_args()
try:
main(args.max_workers, args.keep_going, args.commit, args.packages)
main(args.max_workers, args.keep_going, args.commit, args.packages, args.skip_prompt)
except KeyboardInterrupt as e:
# Lets cancel outside of the main loop too.
sys.exit(130)