|
18 | 18 | import boto3 |
19 | 19 | import click |
20 | 20 | import requests |
21 | | -import senza |
22 | 21 | import yaml |
23 | 22 | from botocore.exceptions import ClientError |
24 | | -from clickclick import (Action, AliasedGroup, FloatRange, OutputFormat, choice, |
25 | | - error, fatal_error, info, ok) |
| 23 | +from clickclick import (Action, FloatRange, OutputFormat, choice, error, |
| 24 | + fatal_error, info, ok) |
26 | 25 | from clickclick.console import print_table |
27 | 26 |
|
28 | | -from .arguments import (json_output_option, output_option, |
| 27 | +from .arguments import (GLOBAL_OPTIONS, json_output_option, output_option, |
29 | 28 | parameter_file_option, region_option, |
30 | 29 | stacktrace_visible_option, watch_option, |
31 | 30 | watchrefresh_option) |
|
43 | 42 | from .patch import patch_auto_scaling_group |
44 | 43 | from .respawn import get_auto_scaling_group, respawn_auto_scaling_group |
45 | 44 | from .stups.piu import Piu |
| 45 | +from .subcommands.config import cmd_config |
| 46 | +from .subcommands.root import cli |
46 | 47 | from .templates import get_template_description, get_templates |
47 | 48 | from .templates._helper import get_mint_bucket_name |
48 | 49 | from .traffic import (change_version_traffic, get_records, |
49 | 50 | print_version_traffic, resolve_to_ip_addresses) |
50 | 51 | from .utils import (camel_case_to_underscore, ensure_keys, named_value, |
51 | 52 | pystache_render) |
52 | 53 |
|
53 | | -CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) |
54 | | - |
55 | 54 | STYLES = { |
56 | 55 | 'RUNNING': {'fg': 'green'}, |
57 | 56 | 'TERMINATED': {'fg': 'red'}, |
|
117 | 116 | 'ResourceStatusReason': 50 |
118 | 117 | } |
119 | 118 |
|
120 | | -GLOBAL_OPTIONS = {} |
121 | | - |
122 | 119 |
|
123 | 120 | def print_json(data, output=None): |
124 | 121 | if output == 'yaml': |
@@ -205,13 +202,6 @@ def watching(w: bool, watch: int): |
205 | 202 | } |
206 | 203 |
|
207 | 204 |
|
208 | | -def print_version(ctx, param, value): |
209 | | - if not value or ctx.resilient_parsing: |
210 | | - return |
211 | | - click.echo('Senza {}'.format(senza.__version__)) |
212 | | - ctx.exit() |
213 | | - |
214 | | - |
215 | 205 | def evaluate(definition, args, account_info, force: bool): |
216 | 206 | # extract Senza* meta information |
217 | 207 | info = definition.pop("SenzaInfo") |
@@ -255,14 +245,6 @@ def evaluate(definition, args, account_info, force: bool): |
255 | 245 | return definition |
256 | 246 |
|
257 | 247 |
|
258 | | -@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) |
259 | | -@click.option('-V', '--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True, |
260 | | - help='Print the current version number and exit.') |
261 | | -@region_option |
262 | | -def cli(region): |
263 | | - GLOBAL_OPTIONS['region'] = region |
264 | | - |
265 | | - |
266 | 248 | class TemplateArguments: |
267 | 249 | def __init__(self, **kwargs): |
268 | 250 | for key, val in kwargs.items(): |
@@ -1634,6 +1616,8 @@ def wait(stack_ref, region, deletion, timeout, interval): |
1634 | 1616 | return |
1635 | 1617 | raise click.Abort() |
1636 | 1618 |
|
| 1619 | +cli.add_command(cmd_config) |
| 1620 | + |
1637 | 1621 |
|
1638 | 1622 | def main(): |
1639 | 1623 | HandleExceptions(cli)() |
|
0 commit comments