
from clint.textui import puts, colored

from elevator.utils.patterns import destructurate

from .helpers import FAILURE_STATUS


def prompt(*args, **kwargs):
    current_db = kwargs.pop('current_db', 'default')

    if current_db:
        pattern = '@ Elevator.{db} => '.format(db=current_db)
    else:
        pattern = '! Offline => '
    input_str = raw_input(pattern)

    return input_str


def parse_input(input_str, *args, **kwargs):
    input_str = input_str.strip().split()
    command, args = destructurate(input_str)
    return command.upper(), args


def output_result(status, result, *args, **kwargs):
    if result:
        if status == FAILURE_STATUS:
            puts(colored.red(str(result)))
        else:
            puts(str(result))


import shlex

from clint.textui import puts, colored

from elevator.utils.patterns import destructurate

from .helpers import FAILURE_STATUS


def prompt(*args, **kwargs):
    current_db = kwargs.pop('current_db', 'default')

    if current_db:
        pattern = '@ Elevator.{db} => '.format(db=current_db)
    else:
        pattern = '! Offline => '
    input_str = raw_input(pattern)

    return input_str


def parse_input(input_str, *args, **kwargs):
    input_str = shlex.split(input_str.strip())
    command, args = destructurate(input_str)
    return command.upper(), args


def output_result(status, result, *args, **kwargs):
    if result:
        if status == FAILURE_STATUS:
            puts(colored.red(str(result)))
        else:
            puts(str(result))

Update : protect cli quoted arguments while parsing
Update : protect cli quoted arguments while parsing

+ 
+ import shlex
  
  from clint.textui import puts, colored
  
  from elevator.utils.patterns import destructurate
  
  from .helpers import FAILURE_STATUS
  
  
  def prompt(*args, **kwargs):
      current_db = kwargs.pop('current_db', 'default')
  
      if current_db:
          pattern = '@ Elevator.{db} => '.format(db=current_db)
      else:
          pattern = '! Offline => '
      input_str = raw_input(pattern)
  
      return input_str
  
  
  def parse_input(input_str, *args, **kwargs):
-     input_str = input_str.strip().split()
+     input_str = shlex.split(input_str.strip())
      command, args = destructurate(input_str)
      return command.upper(), args
  
  
  def output_result(status, result, *args, **kwargs):
      if result:
          if status == FAILURE_STATUS:
              puts(colored.red(str(result)))
          else:
              puts(str(result))
  
Update : protect cli quoted arguments while parsing
## Code Before:

from clint.textui import puts, colored

from elevator.utils.patterns import destructurate

from .helpers import FAILURE_STATUS


def prompt(*args, **kwargs):
    current_db = kwargs.pop('current_db', 'default')

    if current_db:
        pattern = '@ Elevator.{db} => '.format(db=current_db)
    else:
        pattern = '! Offline => '
    input_str = raw_input(pattern)

    return input_str


def parse_input(input_str, *args, **kwargs):
    input_str = input_str.strip().split()
    command, args = destructurate(input_str)
    return command.upper(), args


def output_result(status, result, *args, **kwargs):
    if result:
        if status == FAILURE_STATUS:
            puts(colored.red(str(result)))
        else:
            puts(str(result))

## Instruction:
Update : protect cli quoted arguments while parsing
## Code After:

import shlex

from clint.textui import puts, colored

from elevator.utils.patterns import destructurate

from .helpers import FAILURE_STATUS


def prompt(*args, **kwargs):
    current_db = kwargs.pop('current_db', 'default')

    if current_db:
        pattern = '@ Elevator.{db} => '.format(db=current_db)
    else:
        pattern = '! Offline => '
    input_str = raw_input(pattern)

    return input_str


def parse_input(input_str, *args, **kwargs):
    input_str = shlex.split(input_str.strip())
    command, args = destructurate(input_str)
    return command.upper(), args


def output_result(status, result, *args, **kwargs):
    if result:
        if status == FAILURE_STATUS:
            puts(colored.red(str(result)))
        else:
            puts(str(result))
