# 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




_missing = object()


SUBCOMMAND_METAVAR = 'COMMAND [ARGS]...'
SUBCOMMANDS_METAVAR = 'COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...'



# 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





_missing = object()


SUBCOMMAND_METAVAR = 'COMMAND [ARGS]...'
SUBCOMMANDS_METAVAR = 'COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...'



def _bashcomplete(cmd, prog_name, complete_var=None):