Kevin Cheng | eb85e86 | 2018-10-09 15:35:13 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2018 - The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | r"""Delete args. |
| 17 | |
| 18 | Defines the delete arg parser that holds delete specific args. |
| 19 | """ |
Sam Chiu | 99dfee3 | 2018-11-20 10:19:17 +0800 | [diff] [blame] | 20 | import argparse |
Kevin Cheng | eb85e86 | 2018-10-09 15:35:13 -0700 | [diff] [blame] | 21 | |
| 22 | CMD_DELETE = "delete" |
| 23 | |
| 24 | |
| 25 | def GetDeleteArgParser(subparser): |
| 26 | """Return the delete arg parser. |
| 27 | |
| 28 | Args: |
| 29 | subparser: argparse.ArgumentParser that is attached to main acloud cmd. |
| 30 | |
| 31 | Returns: |
| 32 | argparse.ArgumentParser with delete options defined. |
| 33 | """ |
| 34 | delete_parser = subparser.add_parser(CMD_DELETE) |
| 35 | delete_parser.required = False |
| 36 | delete_parser.set_defaults(which=CMD_DELETE) |
| 37 | delete_parser.add_argument( |
Sam Chiu | 99dfee3 | 2018-11-20 10:19:17 +0800 | [diff] [blame] | 38 | "--instance-names", |
Kevin Cheng | eb85e86 | 2018-10-09 15:35:13 -0700 | [diff] [blame] | 39 | dest="instance_names", |
| 40 | nargs="+", |
| 41 | required=False, |
Sam Chiu | 99dfee3 | 2018-11-20 10:19:17 +0800 | [diff] [blame] | 42 | help="The names of the remote instances that need to delete, " |
| 43 | "separated by spaces, e.g. --instance-names instance-1 instance-2") |
Kevin Cheng | eb85e86 | 2018-10-09 15:35:13 -0700 | [diff] [blame] | 44 | delete_parser.add_argument( |
| 45 | "--all", |
| 46 | action="store_true", |
| 47 | dest="all", |
| 48 | required=False, |
| 49 | help="If more than 1 AVD instance is found, delete them all.") |
| 50 | |
Sam Chiu | 99dfee3 | 2018-11-20 10:19:17 +0800 | [diff] [blame] | 51 | # TODO(b/118439885): Old arg formats to support transition, delete when |
| 52 | # transistion is done. |
| 53 | delete_parser.add_argument( |
| 54 | "--instance_names", |
| 55 | dest="instance_names", |
| 56 | nargs="+", |
| 57 | required=False, |
| 58 | help=argparse.SUPPRESS) |
| 59 | |
Kevin Cheng | eb85e86 | 2018-10-09 15:35:13 -0700 | [diff] [blame] | 60 | return delete_parser |