(args: argparse.Namespace)
| 35 | |
| 36 | |
| 37 | def run(args: argparse.Namespace) -> None: |
| 38 | if args.all_mine and args.instances: |
| 39 | print( |
| 40 | "scratch: error: cannot specify --all-mine and instance IDs", |
| 41 | file=sys.stderr, |
| 42 | ) |
| 43 | sys.exit(1) |
| 44 | |
| 45 | if args.all_mine: |
| 46 | instances = [ |
| 47 | i |
| 48 | for i in list_all_instances() |
| 49 | if i.state |
| 50 | and i.state["Name"] in ("pending", "running", "stopping", "stopped") |
| 51 | ] |
| 52 | elif args.instances: |
| 53 | instances = [get_instance(id) for id in args.instances] |
| 54 | else: |
| 55 | instances = [pick_instance()] |
| 56 | |
| 57 | if not instances: |
| 58 | print("No instances to destroy.") |
| 59 | return |
| 60 | |
| 61 | print("Destroying instances:") |
| 62 | print_instances(instances, args.output_format) |
| 63 | |
| 64 | if not args.yes and not ui.confirm("Would you like to continue?"): |
| 65 | sys.exit(0) |
| 66 | |
| 67 | for instance in instances: |
| 68 | instance.terminate() |
| 69 | print("Instances destroyed.") |
nothing calls this directly
no test coverage detected