Github user ran-z commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/97#discussion_r111683488
  
    --- Diff: aria/cli/cli/aria.py ---
    @@ -0,0 +1,458 @@
    +# Licensed to the Apache Software Foundation (ASF) under one or more
    +# contributor license agreements.  See the NOTICE file distributed with
    +# this work for additional information regarding copyright ownership.
    +# The ASF licenses this file to You under the Apache License, Version 2.0
    +# (the "License"); you may not use this file except in compliance with
    +# the License.  You may obtain a copy of the License at
    +#
    +#     http://www.apache.org/licenses/LICENSE-2.0
    +#
    +# Unless required by applicable law or agreed to in writing, software
    +# distributed under the License is distributed on an "AS IS" BASIS,
    +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +# See the License for the specific language governing permissions and
    +# limitations under the License.
    +
    +
    +import sys
    +import difflib
    +import StringIO
    +import traceback
    +from functools import wraps
    +
    +import click
    +
    +from ..env import env, logger
    +from ..cli import helptexts
    +from ..inputs import inputs_to_dict
    +from ..constants import SAMPLE_SERVICE_TEMPLATE_FILENAME
    +from ...utils.exceptions import get_exception_as_string
    +
    +
    +CLICK_CONTEXT_SETTINGS = dict(
    +    help_option_names=['-h', '--help'],
    +    token_normalize_func=lambda param: param.lower())
    +
    +
    +class MutuallyExclusiveOption(click.Option):
    +    """Makes options mutually exclusive. The option must pass a `cls` 
argument
    +    with this class name and a `mutually_exclusive` argument with a list of
    +    argument names it is mutually exclusive with.
    +
    +    NOTE: All mutually exclusive options must use this. It's not enough to
    +    use it in just one of the options.
    +    """
    +
    +    def __init__(self, *args, **kwargs):
    +        self.mutually_exclusive = set(kwargs.pop('mutually_exclusive', []))
    +        self.mutuality_error_message = \
    +            kwargs.pop('mutuality_error_message',
    +                       helptexts.DEFAULT_MUTUALITY_MESSAGE)
    +        self.mutuality_string = ', '.join(self.mutually_exclusive)
    +        if self.mutually_exclusive:
    +            help = kwargs.get('help', '')
    +            kwargs['help'] = (
    +                '{0}. This argument is mutually exclusive with '
    +                'arguments: [{1}] ({2})'.format(
    +                    help,
    +                    self.mutuality_string,
    +                    self.mutuality_error_message))
    +        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:
    +            raise click.UsageError(
    +                'Illegal usage: `{0}` is mutually exclusive with '
    +                'arguments: [{1}] ({2}).'.format(
    +                    self.name,
    +                    self.mutuality_string,
    +                    self.mutuality_error_message))
    +        return super(MutuallyExclusiveOption, self).handle_parse_result(
    +            ctx, opts, args)
    +
    +
    +def _format_version_data(version_data,
    +                         prefix=None,
    +                         suffix=None,
    +                         infix=None):
    +    all_data = version_data.copy()
    +    all_data['prefix'] = prefix or ''
    +    all_data['suffix'] = suffix or ''
    +    all_data['infix'] = infix or ''
    +    output = StringIO.StringIO()
    +    output.write('{prefix}{version}'.format(**all_data))
    +    output.write('{suffix}'.format(**all_data))
    +    return output.getvalue()
    +
    +
    +def show_version(ctx, param, value):
    --- End diff --
    
    its better as an option to the main command


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to