Main function. Parses command, load settings and dispatches accordingly.
(self, argv=None)
| 193 | self._stage_config_overrides.setdefault(self.api_stage, {})[key] = val |
| 194 | |
| 195 | def handle(self, argv=None): |
| 196 | """ |
| 197 | Main function. |
| 198 | Parses command, load settings and dispatches accordingly. |
| 199 | """ |
| 200 | |
| 201 | desc = "Zappa - Deploy Python applications to AWS Lambda" " and API Gateway.\n" |
| 202 | parser = argparse.ArgumentParser(description=desc) |
| 203 | parser.add_argument( |
| 204 | "-v", |
| 205 | "--version", |
| 206 | action="version", |
| 207 | version=__version__, |
| 208 | help="Print the zappa version", |
| 209 | ) |
| 210 | parser.add_argument("--color", default="auto", choices=["auto", "never", "always"]) |
| 211 | |
| 212 | env_parser = argparse.ArgumentParser(add_help=False) |
| 213 | me_group = env_parser.add_mutually_exclusive_group() |
| 214 | all_help = "Execute this command for all of our defined " "Zappa stages." |
| 215 | me_group.add_argument("--all", action="store_true", help=all_help) |
| 216 | me_group.add_argument("stage_env", nargs="?") |
| 217 | |
| 218 | group = env_parser.add_argument_group() |
| 219 | group.add_argument("-a", "--app_function", help="The WSGI application function.") |
| 220 | group.add_argument("-s", "--settings_file", help="The path to a Zappa settings file.") |
| 221 | group.add_argument("-q", "--quiet", action="store_true", help="Silence all output.") |
| 222 | # https://github.com/Miserlou/Zappa/issues/407 |
| 223 | # Moved when 'template' command added. |
| 224 | # Fuck Terraform. |
| 225 | group.add_argument( |
| 226 | "-j", |
| 227 | "--json", |
| 228 | action="store_true", |
| 229 | help="Make the output of this command be machine readable.", |
| 230 | ) |
| 231 | # https://github.com/Miserlou/Zappa/issues/891 |
| 232 | group.add_argument("--disable_progress", action="store_true", help="Disable progress bars.") |
| 233 | group.add_argument("--no_venv", action="store_true", help="Skip venv check.") |
| 234 | group.add_argument( |
| 235 | "--create-settings", |
| 236 | action="store_true", |
| 237 | help="Create a default zappa_settings.json file if none exists and no environment variables are set.", |
| 238 | ) |
| 239 | |
| 240 | ## |
| 241 | # Certify |
| 242 | ## |
| 243 | subparsers = parser.add_subparsers(title="subcommands", dest="command") |
| 244 | cert_parser = subparsers.add_parser("certify", parents=[env_parser], help="Create and install SSL certificate") |
| 245 | cert_parser.add_argument( |
| 246 | "--manual", |
| 247 | action="store_true", |
| 248 | help=("Gets new Let's Encrypt certificates, but prints them to console." "Does not update API Gateway domains."), |
| 249 | ) |
| 250 | cert_parser.add_argument("-y", "--yes", action="store_true", help="Auto confirm yes.") |
| 251 | |
| 252 | ## |