diff options
author | John Estabrook <jestabro@vyos.io> | 2023-11-27 21:25:46 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-11-27 21:25:46 -0600 |
commit | 0fae5b412a359874f1d61a5330064e87a7e6b899 (patch) | |
tree | 0e752ef473a185400abbe6e479681712614af1b8 /src/op_mode/image_manager.py | |
parent | bb578a1cab177e8cee6e4d02144d21387ba13a93 (diff) | |
download | vyos-1x-0fae5b412a359874f1d61a5330064e87a7e6b899.tar.gz vyos-1x-0fae5b412a359874f1d61a5330064e87a7e6b899.zip |
image-tools: T5751: add arg no_prompt for non-interactive calls
Diffstat (limited to 'src/op_mode/image_manager.py')
-rwxr-xr-x | src/op_mode/image_manager.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/op_mode/image_manager.py b/src/op_mode/image_manager.py index dcbd290c9..e75485f9f 100755 --- a/src/op_mode/image_manager.py +++ b/src/op_mode/image_manager.py @@ -36,7 +36,7 @@ MSG_DELETE_IMAGE_DEFAULT: str = 'Default image cannot be deleted; set another im @compat.grub_cfg_update def delete_image(image_name: Optional[str] = None, - prompt: bool = True) -> None: + no_prompt: bool = False) -> None: """Remove installed image files and boot entry Args: @@ -44,7 +44,7 @@ def delete_image(image_name: Optional[str] = None, """ available_images: list[str] = grub.version_list() if image_name is None: - if not prompt: + if no_prompt: exit('An image name is required for delete action') else: image_name = select_entry(available_images, @@ -60,8 +60,9 @@ def delete_image(image_name: Optional[str] = None, if not persistence_storage: exit('Persistence storage cannot be found') - if not ask_yes_no(f'Do you really want to delete the image {image_name}?', - default=False): + if (not no_prompt and + not ask_yes_no(f'Do you really want to delete the image {image_name}?', + default=False)): exit() # remove files and menu entry @@ -171,6 +172,8 @@ def parse_arguments() -> Namespace: choices=['delete', 'set', 'rename', 'list'], required=True, help='action to perform with an image') + parser.add_argument('--no-prompt', action='store_true', + help='perform action non-interactively') parser.add_argument( '--image-name', help= @@ -189,7 +192,7 @@ if __name__ == '__main__': try: args: Namespace = parse_arguments() if args.action == 'delete': - delete_image(args.image_name) + delete_image(args.image_name, args.no_prompt) if args.action == 'set': set_image(args.image_name) if args.action == 'rename': |