Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/awscli/commands.py
1566 views
1
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
14
15
class CLICommand:
16
"""Interface for a CLI command.
17
18
This class represents a top level CLI command
19
(``aws ec2``, ``aws s3``, ``aws config``).
20
21
"""
22
23
@property
24
def name(self):
25
# Subclasses must implement a name.
26
raise NotImplementedError("name")
27
28
@name.setter
29
def name(self, value):
30
# Subclasses must implement setting/changing the cmd name.
31
raise NotImplementedError("name")
32
33
@property
34
def lineage(self):
35
# Represents how to get to a specific command using the CLI.
36
# It includes all commands that came before it and itself in
37
# a list.
38
return [self]
39
40
@property
41
def lineage_names(self):
42
# Represents the lineage of a command in terms of command ``name``
43
return [cmd.name for cmd in self.lineage]
44
45
def __call__(self, args, parsed_globals):
46
"""Invoke CLI operation.
47
48
:type args: str
49
:param args: The remaining command line args.
50
51
:type parsed_globals: ``argparse.Namespace``
52
:param parsed_globals: The parsed arguments so far.
53
54
:rtype: int
55
:return: The return code of the operation. This will be used
56
as the RC code for the ``aws`` process.
57
58
"""
59
# Subclasses are expected to implement this method.
60
pass
61
62
def create_help_command(self):
63
# Subclasses are expected to implement this method if they want
64
# help docs.
65
return None
66
67
@property
68
def arg_table(self):
69
return {}
70
71