Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Command line based invoke framework.

Project description

Installing

pip3 install throttle

Usage

import lineopt

# dict w/ extra methods
state = lineopt.State()

@state.sub('echo')
def state_0(argument):

  return argument

@state_0.sub('loud')
def state_0_0(argument):

  return argument.upper()

flags = {'-c': 'content', '-s': 'meddle'}

@state_0.sub('fancy', flags)
def state_0_1(arguments):

  content = arguments['-c']

  meddle = arguments.get('-s', ' ')

  return meddle.join(content)

starts = ('!', '.')

def parse(value, starts = starts):

  try:

    (start, names, argument, function) = state.context(starts, value)

  except (KeyError, ValueError) as error:

    raise

    result = repr(error)

  else:

    result = function(argument)

  print(result)

say = 'vocalizing is fun' # argument

parse(f'!echo {say}') # vocalizing is fun
parse(f'.echo.loud {say}') # VOCALIZING IS FUN
parse(f'!echo.fancy -c {say}') # v o c a l i z i n g   i s   f u n
parse(f'.echo.fancy {say} -s ~') # v~o~c~a~l~i~z~i~n~g~ ~i~s~ ~f~u~n
parse(f'-echo.loud {say}') # ValueError: 'invalid start'
parse(f'.fancy {say}') # KeyError: 'fancy' (only sub of echo)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lineopt, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size lineopt-0.0.4-py3-none-any.whl (3.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size lineopt-0.0.4.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page