Skip to main content

Command line based invoke framework.

Project description


pip3 install throttle


import lineopt

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

def state_0(argument):

  return argument

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


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

  except (KeyError, ValueError) as error:


    result = repr(error)


    result = function(argument)


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.

Source Distribution

lineopt-0.0.3.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

lineopt-0.0.3-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page