effusiveperiscope / repple

Quick and dirty fdisk-like REPLs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repple

Quick and dirty opinionated fdisk-style REPLs

  • Whitespace-separated command and arguments
  • Except unary string functions
  • Selector prompt
from repple import Repple
r = Repple()
r['a'] = (lambda x: print(x+1), "Adds one to first argument and prints it")
r['A'] = lambda x: print(x+2)
def variadic_fn(*args):
  print(*[a+1 for a in args])

r.main()
Command: h
        q               Exits the program
        h               Show this help
        a <x>           Adds one to first argument and prints it
        A <x>
        b <args>
Command: a 1
2
Command: A 1
3
Command: b 1 2
2 3

Selector

from repple import Repple
r = Repple()
r['a'] = lambda: print(Repple.selector(['a','b','c']))
r.main()
Command: a
        1: a
        2: b
        3: c
Select your items: 1 3
['a', 'c']

Unary string function

from repple import Repple
r = Repple()
r.add_string_func('p', lambda x: print(x))
r.main()
Command: p Hello world!
Hello world!

About

Quick and dirty fdisk-like REPLs


Languages

Language:Python 100.0%