• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2022, The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Script that generates arguments for autocompletion."""
16
17import argparse
18
19from atest import arg_parser
20
21
22def _get_optional_args(parser: argparse.ArgumentParser) -> list[str]:
23  """Get args from actions and return optional args.
24
25  Returns:
26      A list of optional arguments.
27  """
28  argument_list = []
29  # The output of _get_optional_actions(): [['-t', '--test']]
30  # return an argument list: ['-t', '--test']
31  for arg in parser._get_optional_actions():
32    argument_list.extend(arg.option_strings)
33  return argument_list
34
35
36if __name__ == '__main__':
37  print('\n'.join(_get_optional_args(arg_parser.create_atest_arg_parser())))
38