# Path: scalrctl/click/types.py
# def convert_type(ty, default=None):
#     """Converts a callable or python ty into the most appropriate param
#     ty.
#     """
#     guessed_type = False
#     if ty is None and default is not None:
#         if isinstance(default, tuple):
#             ty = tuple(map(type, default))
#         else:
#             ty = type(default)
#         guessed_type = True
# 
#     if isinstance(ty, tuple):
#         return Tuple(ty)
#     if isinstance(ty, ParamType):
#         return ty
#     if ty is text_type or ty is str or ty is None:
#         return STRING
#     if ty is int:
#         return INT
#     # Booleans are only okay if not guessed.  This is done because for
#     # flags the default value is actually a bit of a lie in that it
#     # indicates which of the flags is the one we want.  See get_default()
#     # for more information.
#     if ty is bool and not guessed_type:
#         return BOOL
#     if ty is float:
#         return FLOAT
#     if guessed_type:
#         return STRING
# 
#     # Catch a common mistake
#     if __debug__:
#         try:
#             if issubclass(ty, ParamType):
#                 raise AssertionError('Attempted to use an uninstantiated '
#                                      'parameter type (%s).' % ty)
#         except TypeError:
#             pass
#     return FuncParamType(ty)
# 
# class IntRange(IntParamType):
#     """A parameter that works similar to :data:`click.INT` but restricts
#     the value to fit into a range.  The default behavior is to fail if the
#     value falls outside the range, but it can also be silently clamped
#     between the two edges.
# 
#     See :ref:`ranges` for an example.
#     """
#     name = 'integer range'
# 
#     def __init__(self, min=None, max=None, clamp=False):
#         self.min = min
#         self.max = max
#         self.clamp = clamp
# 
#     def convert(self, value, param, ctx):
#         rv = IntParamType.convert(self, value, param, ctx)
#         if self.clamp:
#             if self.min is not None and rv < self.min:
#                 return self.min
#             if self.max is not None and rv > self.max:
#                 return self.max
#         if self.min is not None and rv < self.min or \
#            self.max is not None and rv > self.max:
#             if self.min is None:
#                 self.fail('%s is bigger than the maximum valid value '
#                           '%s.' % (rv, self.max), param, ctx)
#             elif self.max is None:
#                 self.fail('%s is smaller than the minimum valid value '
#                           '%s.' % (rv, self.min), param, ctx)
#             else:
#                 self.fail('%s is not in the valid range of %s to %s.'
#                           % (rv, self.min, self.max), param, ctx)
#         return rv
# 
#     def __repr__(self):
#         return 'IntRange(%r, %r)' % (self.min, self.max)
# 
# BOOL = BoolParamType()


import os
import sys
from contextlib import contextmanager
from itertools import repeat
from functools import update_wrapper
from .types import convert_type, IntRange, BOOL
from .utils import make_str, make_default_short_help, echo, get_os_args
from .exceptions import ClickException, UsageError, BadParameter, Abort, \
     MissingParameter
from .termui import prompt, confirm
from .formatting import HelpFormatter, join_options
from .parser import OptionParser, split_opt
from .globals import push_context, pop_context
from ._compat import PY2, isidentifier, iteritems
from ._unicodefun import _check_for_unicode_literals, _verify_python3_env
    from ._bashcomplete import bashcomplete
        from warnings import warn
from .decorators import command, group
    :param required: controls if this is optional or not.
    :param default: the default value if omitted.  This can also be a callable,
                    in which case it's invoked when the default is needed
                    without any arguments.
    :param callback: a callback that should be executed after the parameter
                     was matched.  This is called as ``fn(ctx, param,
                     value)`` and needs to return the value.  Before Click
                     2.0, the signature was ``(ctx, value)``.
    :param nargs: the number of arguments to match.  If not ``1`` the return
                  value is a tuple instead of single value.  The default for
                  nargs is ``1`` (except if the type is a tuple, then it's
                  the arity of the tuple).
    :param metavar: how the value is represented in the help page.
    :param expose_value: if this is `True` then the value is passed onwards
                         to the command callback and stored on the context,
                         otherwise it's skipped.
    :param is_eager: eager values are processed before non eager ones.  This
                     should not be set for arguments or it will inverse the
                     order of processing.
    :param envvar: a string or list of strings that are environment variables
                   that should be checked.
    """
    param_type_name = 'parameter'

    def __init__(self, param_decls=None, type=None, required=False,
                 default=None, callback=None, nargs=None, metavar=None,
                 expose_value=True, is_eager=False, envvar=None):
        self.name, self.opts, self.secondary_opts = \
            self._parse_decls(param_decls or (), expose_value)


# Path: scalrctl/click/types.py
# def convert_type(ty, default=None):
#     """Converts a callable or python ty into the most appropriate param
#     ty.
#     """
#     guessed_type = False
#     if ty is None and default is not None:
#         if isinstance(default, tuple):
#             ty = tuple(map(type, default))
#         else:
#             ty = type(default)
#         guessed_type = True
# 
#     if isinstance(ty, tuple):
#         return Tuple(ty)
#     if isinstance(ty, ParamType):
#         return ty
#     if ty is text_type or ty is str or ty is None:
#         return STRING
#     if ty is int:
#         return INT
#     # Booleans are only okay if not guessed.  This is done because for
#     # flags the default value is actually a bit of a lie in that it
#     # indicates which of the flags is the one we want.  See get_default()
#     # for more information.
#     if ty is bool and not guessed_type:
#         return BOOL
#     if ty is float:
#         return FLOAT
#     if guessed_type:
#         return STRING
# 
#     # Catch a common mistake
#     if __debug__:
#         try:
#             if issubclass(ty, ParamType):
#                 raise AssertionError('Attempted to use an uninstantiated '
#                                      'parameter type (%s).' % ty)
#         except TypeError:
#             pass
#     return FuncParamType(ty)
# 
# class IntRange(IntParamType):
#     """A parameter that works similar to :data:`click.INT` but restricts
#     the value to fit into a range.  The default behavior is to fail if the
#     value falls outside the range, but it can also be silently clamped
#     between the two edges.
# 
#     See :ref:`ranges` for an example.
#     """
#     name = 'integer range'
# 
#     def __init__(self, min=None, max=None, clamp=False):
#         self.min = min
#         self.max = max
#         self.clamp = clamp
# 
#     def convert(self, value, param, ctx):
#         rv = IntParamType.convert(self, value, param, ctx)
#         if self.clamp:
#             if self.min is not None and rv < self.min:
#                 return self.min
#             if self.max is not None and rv > self.max:
#                 return self.max
#         if self.min is not None and rv < self.min or \
#            self.max is not None and rv > self.max:
#             if self.min is None:
#                 self.fail('%s is bigger than the maximum valid value '
#                           '%s.' % (rv, self.max), param, ctx)
#             elif self.max is None:
#                 self.fail('%s is smaller than the minimum valid value '
#                           '%s.' % (rv, self.min), param, ctx)
#             else:
#                 self.fail('%s is not in the valid range of %s to %s.'
#                           % (rv, self.min, self.max), param, ctx)
#         return rv
# 
#     def __repr__(self):
#         return 'IntRange(%r, %r)' % (self.min, self.max)
# 
# BOOL = BoolParamType()


# Path: scalrctl/click/core.py
import os
import sys
from contextlib import contextmanager
from itertools import repeat
from functools import update_wrapper
from .types import convert_type, IntRange, BOOL
from .utils import make_str, make_default_short_help, echo, get_os_args
from .exceptions import ClickException, UsageError, BadParameter, Abort, \
     MissingParameter
from .termui import prompt, confirm
from .formatting import HelpFormatter, join_options
from .parser import OptionParser, split_opt
from .globals import push_context, pop_context
from ._compat import PY2, isidentifier, iteritems
from ._unicodefun import _check_for_unicode_literals, _verify_python3_env
    from ._bashcomplete import bashcomplete
        from warnings import warn
from .decorators import command, group

    :param required: controls if this is optional or not.
    :param default: the default value if omitted.  This can also be a callable,
                    in which case it's invoked when the default is needed
                    without any arguments.
    :param callback: a callback that should be executed after the parameter
                     was matched.  This is called as ``fn(ctx, param,
                     value)`` and needs to return the value.  Before Click
                     2.0, the signature was ``(ctx, value)``.
    :param nargs: the number of arguments to match.  If not ``1`` the return
                  value is a tuple instead of single value.  The default for
                  nargs is ``1`` (except if the type is a tuple, then it's
                  the arity of the tuple).
    :param metavar: how the value is represented in the help page.
    :param expose_value: if this is `True` then the value is passed onwards
                         to the command callback and stored on the context,
                         otherwise it's skipped.
    :param is_eager: eager values are processed before non eager ones.  This
                     should not be set for arguments or it will inverse the
                     order of processing.
    :param envvar: a string or list of strings that are environment variables
                   that should be checked.
    """
    param_type_name = 'parameter'

    def __init__(self, param_decls=None, type=None, required=False,
                 default=None, callback=None, nargs=None, metavar=None,
                 expose_value=True, is_eager=False, envvar=None):
        self.name, self.opts, self.secondary_opts = \
            self._parse_decls(param_decls or (), expose_value)


        self.type = convert_type(type, default)