blob: 4d8cd8c24b936bf4410b732a99c6a2ef9ac6c477 [file] [log] [blame]
Simran Basif231db12015-09-23 11:38:14 -07001#
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
16from __future__ import print_function
Simran Basif231db12015-09-23 11:38:14 -070017import sys
18
19from command import Command, GitcClientCommand
Renaud Paquaya65adf72016-11-03 10:37:53 -070020import platform_utils
Simran Basif231db12015-09-23 11:38:14 -070021
22from pyversion import is_python3
23if not is_python3():
Simran Basif231db12015-09-23 11:38:14 -070024 input = raw_input
Simran Basif231db12015-09-23 11:38:14 -070025
26class GitcDelete(Command, GitcClientCommand):
27 common = True
28 visible_everywhere = False
29 helpSummary = "Delete a GITC Client."
30 helpUsage = """
31%prog
32"""
33 helpDescription = """
34This subcommand deletes the current GITC client, deleting the GITC manifest
35and all locally downloaded sources.
36"""
37
38 def _Options(self, p):
39 p.add_option('-f', '--force',
40 dest='force', action='store_true',
41 help='Force the deletion (no prompt).')
42
43 def Execute(self, opt, args):
44 if not opt.force:
45 prompt = ('This will delete GITC client: %s\nAre you sure? (yes/no) ' %
46 self.gitc_manifest.gitc_client_name)
47 response = input(prompt).lower()
48 if not response == 'yes':
49 print('Response was not "yes"\n Exiting...')
50 sys.exit(1)
Renaud Paquaya65adf72016-11-03 10:37:53 -070051 platform_utils.rmtree(self.gitc_manifest.gitc_client_dir)