Simran Basi | f231db1 | 2015-09-23 11:38:14 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2015 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | from __future__ import print_function |
Simran Basi | f231db1 | 2015-09-23 11:38:14 -0700 | [diff] [blame] | 17 | import shutil |
| 18 | import sys |
| 19 | |
| 20 | from command import Command, GitcClientCommand |
Simran Basi | f231db1 | 2015-09-23 11:38:14 -0700 | [diff] [blame] | 21 | |
| 22 | from pyversion import is_python3 |
| 23 | if not is_python3(): |
| 24 | # pylint:disable=W0622 |
| 25 | input = raw_input |
| 26 | # pylint:enable=W0622 |
| 27 | |
| 28 | class GitcDelete(Command, GitcClientCommand): |
| 29 | common = True |
| 30 | visible_everywhere = False |
| 31 | helpSummary = "Delete a GITC Client." |
| 32 | helpUsage = """ |
| 33 | %prog |
| 34 | """ |
| 35 | helpDescription = """ |
| 36 | This subcommand deletes the current GITC client, deleting the GITC manifest |
| 37 | and all locally downloaded sources. |
| 38 | """ |
| 39 | |
| 40 | def _Options(self, p): |
| 41 | p.add_option('-f', '--force', |
| 42 | dest='force', action='store_true', |
| 43 | help='Force the deletion (no prompt).') |
| 44 | |
| 45 | def Execute(self, opt, args): |
| 46 | if not opt.force: |
| 47 | prompt = ('This will delete GITC client: %s\nAre you sure? (yes/no) ' % |
| 48 | self.gitc_manifest.gitc_client_name) |
| 49 | response = input(prompt).lower() |
| 50 | if not response == 'yes': |
| 51 | print('Response was not "yes"\n Exiting...') |
| 52 | sys.exit(1) |
| 53 | shutil.rmtree(self.gitc_manifest.gitc_client_dir) |