# Path: jubakit/_cli/util.py
# def shell_split(s):
#   return shlex.split(s)


import inspect
from jubatus.common import Datum
from .util import shell_split
class Mandatory(Requirement):
  def __init__(self, t):
    self.t = t

  def convert(self, args):
    if issubclass(self.t, Type):
      return self.t().convert(args)
    else:
      return (1, self.t(args[0]))

  def min_max(self):
    if issubclass(self.t, Type):
      return self.t().min_max()
    else:
      return (1, 1)

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])

def Arguments(*expected_types):
  def wrap_by_preprocessor(func):
    assert len(inspect.getargspec(func).args) == (len(expected_types) + 1)

    def preprocessor(self, line):

# Path: jubakit/_cli/util.py
# def shell_split(s):
#   return shlex.split(s)


# Path: jubakit/_cli/args.py
import inspect
from jubatus.common import Datum
from .util import shell_split

class Mandatory(Requirement):
  def __init__(self, t):
    self.t = t

  def convert(self, args):
    if issubclass(self.t, Type):
      return self.t().convert(args)
    else:
      return (1, self.t(args[0]))

  def min_max(self):
    if issubclass(self.t, Type):
      return self.t().min_max()
    else:
      return (1, 1)

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])

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)