| 107 | display_attributes = ["user", "token", "expiry"] |
| 108 | |
| 109 | def __init__(self, resource, *args, **kwargs): |
| 110 | |
| 111 | kwargs["has_token_opt"] = False |
| 112 | |
| 113 | super(LoginCommand, self).__init__( |
| 114 | resource, |
| 115 | kwargs.pop("name", "create"), |
| 116 | "Authenticate user, acquire access token, and update CLI config directory", |
| 117 | *args, |
| 118 | **kwargs, |
| 119 | ) |
| 120 | |
| 121 | self.parser.add_argument("username", help="Name of the user to authenticate.") |
| 122 | |
| 123 | self.parser.add_argument( |
| 124 | "-p", |
| 125 | "--password", |
| 126 | dest="password", |
| 127 | help="Password for the user. If password is not provided, " |
| 128 | "it will be prompted for.", |
| 129 | ) |
| 130 | self.parser.add_argument( |
| 131 | "-l", |
| 132 | "--ttl", |
| 133 | type=int, |
| 134 | dest="ttl", |
| 135 | default=None, |
| 136 | help="The life span of the token in seconds. " |
| 137 | "Max TTL configured by the admin supersedes this.", |
| 138 | ) |
| 139 | self.parser.add_argument( |
| 140 | "-w", |
| 141 | "--write-password", |
| 142 | action="store_true", |
| 143 | default=False, |
| 144 | dest="write_password", |
| 145 | help="Write the password in plain text to the config file " |
| 146 | "(default is to omit it)", |
| 147 | ) |
| 148 | |
| 149 | def run(self, args, **kwargs): |
| 150 | |