# Path: jubakit/_stdio.py
# @classmethod
# def print(cls, *args, **kwargs):
#   builtins.print(file=cls.stdout, *args, **kwargs)
# 
# Path: jubakit/_cli/cmd.py
# class ExtendedCmd(cmd.Cmd, object):
#   """
#   Extended framework of standard cmd.Cmd class with better completion
#   support and alias features.
#   """
# 
#   def parseline(self, line):
#     line = line.strip()
#     if not line:
#       return None, None, line
#     elif line[0] == '?':
#       line = 'help ' + line[1:]
#     elif line[0] == '!':
#       if hasattr(self, 'do_shell'):
#         line = 'shell ' + line[1:]
#       else:
#         return None, None, line
#     i, n = 0, len(line)
#     while i < n and line[i] in self.identchars: i = i+1
#     cmd, arg = line[:i], line[i:].strip()
#     return cmd, arg, line
# 
#   def complete(self, text, state):
#     result = super(ExtendedCmd, self).complete(text, state)
#     if len(self.completion_matches) == 1:
#       return self.completion_matches[state] + ' ' if state == 0 else None
#     return result
# 
#   def register_alias(self, alias, name):
#     """
#     Register alias function to the method.
#     Aliases are not listed by `help` command.
#     """
#     self.__dict__['do_' + alias] = getattr(self, name)
# 
# Path: jubakit/_cli/args.py
# def Arguments(*expected_types):
#   def wrap_by_preprocessor(func):
#     assert len(inspect.getargspec(func).args) == (len(expected_types) + 1)
# 
#     def preprocessor(self, line):
#       params = shell_split(line)
#       types = []
#       (min_count, max_count) = (0, 0)
# 
#       for t in expected_types:
#         if not isinstance(t, Requirement):
#           t = Mandatory(t)
#         types.append(t)
#         (t_min, t_max) = t.min_max()
#         min_count += t_min
#         if t_max is None:
#           max_count = None
#         elif max_count is not None:
#           max_count += t_max
# 
#       params_len = len(params)
#       if params_len < min_count:
#         raise ValueError('Too few arguments ({0} required at least, only got {1})'.format(min_count, params_len))
#       if max_count is not None and max_count < params_len:
#         raise ValueError('Too many arguments ({0} required at most, got {1})'.format(max_count, params_len))
# 
#       index = 0
#       argv = []
#       for t in types:
#         try:
#           (consumed, value) = t.convert(params[index:])
#         except ValueError as e:
#           raise ValueError('argument {0}: {1}'.format(index + 1, e))
#         argv.append(value)
#         index += consumed
#       return func(self, *argv)
#     preprocessor.__doc__ = func.__doc__
#     return preprocessor
#   return wrap_by_preprocessor
# 
# class Optional(Mandatory):
#   def convert(self, args):
#     if len(args) == 0:
#       return (0, None)
#     return super(Optional, self).convert(args)
# 
#   def min_max(self):
#     return (0, super(Optional, self).min_max()[1])


import subprocess
from .._stdio import print
from .cmd import ExtendedCmd
from .args import Arguments, Optional
  #################################################################
  # Common interfaces for Jubatus CLI
  #################################################################

  @classmethod
  def _name(cls):
    """
    Returns the name of the service (e.g., `classifier`).
    You must override this in subclasses.
    """
    raise NotImplementedError

  def _verbose(self, msg):
    """
    Outputs logs only when in verbose mode.
    """
    if self._sh._verbose:
      print(msg)

  @property
  def client(self):
    """
    Returns the client instance.
    """
    return self._sh.get_client()

  #################################################################
  # Built-in shell commands
  #################################################################


# Path: jubakit/_stdio.py
# @classmethod
# def print(cls, *args, **kwargs):
#   builtins.print(file=cls.stdout, *args, **kwargs)
# 
# Path: jubakit/_cli/cmd.py
# class ExtendedCmd(cmd.Cmd, object):
#   """
#   Extended framework of standard cmd.Cmd class with better completion
#   support and alias features.
#   """
# 
#   def parseline(self, line):
#     line = line.strip()
#     if not line:
#       return None, None, line
#     elif line[0] == '?':
#       line = 'help ' + line[1:]
#     elif line[0] == '!':
#       if hasattr(self, 'do_shell'):
#         line = 'shell ' + line[1:]
#       else:
#         return None, None, line
#     i, n = 0, len(line)
#     while i < n and line[i] in self.identchars: i = i+1
#     cmd, arg = line[:i], line[i:].strip()
#     return cmd, arg, line
# 
#   def complete(self, text, state):
#     result = super(ExtendedCmd, self).complete(text, state)
#     if len(self.completion_matches) == 1:
#       return self.completion_matches[state] + ' ' if state == 0 else None
#     return result
# 
#   def register_alias(self, alias, name):
#     """
#     Register alias function to the method.
#     Aliases are not listed by `help` command.
#     """
#     self.__dict__['do_' + alias] = getattr(self, name)
# 
# Path: jubakit/_cli/args.py
# def Arguments(*expected_types):
#   def wrap_by_preprocessor(func):
#     assert len(inspect.getargspec(func).args) == (len(expected_types) + 1)
# 
#     def preprocessor(self, line):
#       params = shell_split(line)
#       types = []
#       (min_count, max_count) = (0, 0)
# 
#       for t in expected_types:
#         if not isinstance(t, Requirement):
#           t = Mandatory(t)
#         types.append(t)
#         (t_min, t_max) = t.min_max()
#         min_count += t_min
#         if t_max is None:
#           max_count = None
#         elif max_count is not None:
#           max_count += t_max
# 
#       params_len = len(params)
#       if params_len < min_count:
#         raise ValueError('Too few arguments ({0} required at least, only got {1})'.format(min_count, params_len))
#       if max_count is not None and max_count < params_len:
#         raise ValueError('Too many arguments ({0} required at most, got {1})'.format(max_count, params_len))
# 
#       index = 0
#       argv = []
#       for t in types:
#         try:
#           (consumed, value) = t.convert(params[index:])
#         except ValueError as e:
#           raise ValueError('argument {0}: {1}'.format(index + 1, e))
#         argv.append(value)
#         index += consumed
#       return func(self, *argv)
#     preprocessor.__doc__ = func.__doc__
#     return preprocessor
#   return wrap_by_preprocessor
# 
# class Optional(Mandatory):
#   def convert(self, args):
#     if len(args) == 0:
#       return (0, None)
#     return super(Optional, self).convert(args)
# 
#   def min_max(self):
#     return (0, super(Optional, self).min_max()[1])


# Path: jubakit/_cli/base.py
import subprocess
from .._stdio import print
from .cmd import ExtendedCmd
from .args import Arguments, Optional

  #################################################################
  # Common interfaces for Jubatus CLI
  #################################################################

  @classmethod
  def _name(cls):
    """
    Returns the name of the service (e.g., `classifier`).
    You must override this in subclasses.
    """
    raise NotImplementedError

  def _verbose(self, msg):
    """
    Outputs logs only when in verbose mode.
    """
    if self._sh._verbose:
      print(msg)

  @property
  def client(self):
    """
    Returns the client instance.
    """
    return self._sh.get_client()

  #################################################################
  # Built-in shell commands
  #################################################################


  @Arguments()