• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#
3# Copyright 2016 - 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
17"""Common code used by both acloud and acloud_kernel tools."""
18
19import argparse
20
21
22def AddCommonArguments(parser):
23    """Adds arguments common to parsers.
24
25    Args:
26        parser: ArgumentParser object, used to parse flags.
27    """
28    parser.add_argument("--email",
29                        type=str,
30                        dest="email",
31                        help="Email account to use for authentcation.")
32    parser.add_argument("--config-file",
33                        type=str,
34                        dest="config_file",
35                        default=None,
36                        help="Path to the config file, default to "
37                        "acloud.config in the current working directory.")
38    parser.add_argument("--service-account-json-private-key-path",
39                        type=str,
40                        dest="service_account_json_private_key_path",
41                        help="Path to service account's json private key "
42                        "file.")
43    parser.add_argument("--report-file",
44                        type=str,
45                        dest="report_file",
46                        default=None,
47                        help="Dump the report this file in json format. "
48                        "If not specified, just log the report.")
49    parser.add_argument("--log-file",
50                        dest="log_file",
51                        type=str,
52                        default=None,
53                        help="Path to log file.")
54    parser.add_argument('--verbose', '-v',
55                        action='count',
56                        default=0,
57                        help="Enable verbose log. Use --verbose or -v for "
58                        "logging at INFO level, and -vv for DEBUG level.")
59
60    # Allow for using the underscore args as well to keep it backward
61    # compatible with the infra use case. Remove when g3 acloud is
62    # deprecated (b/118439885).
63    parser.add_argument("--config_file",
64                        type=str,
65                        dest="config_file",
66                        default=None,
67                        help=argparse.SUPPRESS)
68    parser.add_argument("--service_account_json_private_key_path",
69                        type=str,
70                        dest="service_account_json_private_key_path",
71                        help=argparse.SUPPRESS)
72    parser.add_argument("--report_file",
73                        type=str,
74                        dest="report_file",
75                        default=None,
76                        help=argparse.SUPPRESS)
77    parser.add_argument("--log_file",
78                        dest="log_file",
79                        type=str,
80                        default=None,
81                        help=argparse.SUPPRESS)
82