-
Notifications
You must be signed in to change notification settings - Fork 47
Conversation
Can one of the admins verify this patch? |
cd5f233
to
cf08b4b
Compare
aria/cli/helptexts.py
Outdated
@@ -47,3 +47,8 @@ | |||
SORT_BY = "Key for sorting the list" | |||
DESCENDING = "Sort list in descending order [default: False]" | |||
JSON_OUTPUT = "Output logs in a consumable JSON format" | |||
|
|||
DISPLAY_JSON = "Display in JSON format" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets merge this with JSON_OUTPUT
,
the latter is a good name, and simply have it as "Format the output as JSON"
aria/cli/core/aria.py
Outdated
@@ -325,6 +325,30 @@ def __init__(self): | |||
default=defaults.SERVICE_TEMPLATE_FILENAME, | |||
help=helptexts.SERVICE_TEMPLATE_FILENAME) | |||
|
|||
self.display_json = click.option( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge this with the other JSON one
aria/cli/core/aria.py
Outdated
is_flag=True, | ||
help=helptexts.DISPLAY_JSON) | ||
|
||
self.display_yaml = click.option( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yaml_output
?
aria/cli/commands/services.py
Outdated
logger.info('Displaying service {0}...'.format(service_name)) | ||
service = model_storage.service.get_by_name(service_name) | ||
consumption.ConsumptionContext() | ||
if graph: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General reminder that none of the methods below are standard for the CLI
Fine for now, but keep https://issues.apache.org/jira/browse/ARIA-183 in mind
aria/cli/commands/services.py
Outdated
@aria.options.display_graph | ||
@aria.pass_model_storage | ||
@aria.pass_logger | ||
def display(service_name, model_storage, json, yaml, graph, logger): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicking that model_storage should probably sit after graph
, before logger
@aria.options.display_types | ||
@aria.pass_model_storage | ||
@aria.pass_logger | ||
def display(service_template_name, model_storage, json, yaml, types, logger): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having both display
and show
is confusing :/
I agree however that it doesn't make sense to make this command into a mere flag of show
as they're very different.
I'm generally ok with this as is, but Maxim wanted me to suggest aria parse service/service-template
as an option as well. I'll leave it for your consideration :)
7442a76
to
7e75948
Compare
aria/cli/table.py
Outdated
@@ -85,7 +85,7 @@ def get_values_per_column(column, row_data): | |||
|
|||
return val | |||
else: | |||
return defaults[column] | |||
return defaults.get(column) if defaults is not None else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should instead have a defaults = defaults or {}
before calling the nested method
aria/cli/commands/services.py
Outdated
service = model_storage.service.get_by_name(service_name) | ||
|
||
if json or yaml: | ||
all = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd rename the flag, it's both unclear and a python keyword. show_all
or all_info
might be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i actually didnt mean the flag but only the variables etc.,
although now that i think of it it might also be better to change the flag, as it might be confusing i.e. users might think it will show all service-templates or so..?
in any case what matters to me more is the variables, the flag can still be all
to the user, but the "destination" of the variable (configurable in aria.py
) should be renamed.
aria/cli/commands/services.py
Outdated
service = model_storage.service.get_by_name(service_name) | ||
|
||
if json or yaml: | ||
all = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i actually didnt mean the flag but only the variables etc.,
although now that i think of it it might also be better to change the flag, as it might be confusing i.e. users might think it will show all service-templates or so..?
in any case what matters to me more is the variables, the flag can still be all
to the user, but the "destination" of the variable (configurable in aria.py
) should be renamed.
logger.info('Existing services:') | ||
for service in service_template.services: | ||
logger.info('\t{0}'.format(service.name)) | ||
if json or yaml: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm a bit confused by this. so yaml
, json
, and all
all mean all,
and json
and yaml
can be used simulatniously but only json
will get printed.
Re the latter problem, please have a look at aria.py
for how to make flags mutually-exclusive.
re the former, it might be better to also have the all
flag as mutually-exclusive with the other two, (or that possibly using either json
or yaml
requires the all
flag as well..?)
990a792
to
8219354
Compare
aria/cli/core/aria.py
Outdated
'--full', | ||
'mode', | ||
is_flag=True, | ||
flag_value='full', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I don't like this approach as much at the previous one.
It seems like it simplifies the code a bit but makes things somewhat more confusing to the user - specifically the fact that only the last flag of a given "destination" (e.g. mode
) takes hold.
If instead you have different destinations for these flags, it'd be easier to inform the user of misuse (even if for some reason the mutually-exclusive mechanism is problematic to use, you can always just manually validate the parameters in the command function itself)
aria/cli/core/aria.py
Outdated
def __init__(self, *args, **kwargs): | ||
self.mutually_exclusive = set(kwargs.pop('mutually_exclusive', [])) | ||
self.mutually_exclusive = kwargs.pop('mutually_exclusive', tuple()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change this from a set to another type?
aria/cli/core/aria.py
Outdated
@@ -65,15 +58,33 @@ def __init__(self, *args, **kwargs): | |||
super(MutuallyExclusiveOption, self).__init__(*args, **kwargs) | |||
|
|||
def handle_parse_result(self, ctx, opts, args): | |||
if self.mutually_exclusive.intersection(opts) and self.name in opts: | |||
if (self.name in opts) and self.mutually_exclusive.keys().intersection(opts): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like mutually_exclusive
might be a tuple
now, so .keys()
would raise an error here.
aria/cli/core/aria.py
Outdated
|
||
def mutually_exclusive_option(*param_decls, **attrs): | ||
""" | ||
Makes options mutually exclusive. The decorator must pass a a ``mutually_exclusive`` argument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a a a a a
aria/cli/core/aria.py
Outdated
options. | ||
""" | ||
def decorator(func): | ||
if 'help' in attrs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please document this func a bit more?
I'm not sure what are param_decls
and attrs
in this case, why help
is being inspected, and why the internal __click_params__
is accessed directly here.
* Allow "--full" flag to provide a complete dump * Allow "--json" and "--yaml" flags for dump in those formats * Support for node graph and type hierarchies * Some fixes for YAML dump for our custom types * Also closes ARIA-186: "aria services show" command
8219354
to
fdd57c4
Compare
Also includes some typo fixes for the CLI.