Skip to main content

Automatically generate a simple CLI.

Project description


Automatically generate a simple CLI.


pip install funcli

Basic Usage

def main(*args: int):
	print("Sum:", sum(args))

if __name__ == '__main__':
	import funcli

# $ python 1 2 3
# Sum: 6


funcli.main(spec = None)

Sugar. spec defaults to the main function from the caller's scope. Calls on spec, and calls sys.exit with the return value., args = None, converters = None)
  • spec is either a callable, a sequence of callables, or a dict mapping strings to nested specs
  • args default to sys.argv[1:]
  • converters is a mapping from types (or whatever you want to use as annotations) to a function that parses a command line argument

Given functions foo, bar, baz, here are some sample invocations:, ['arg0']) # Calls foo('arg0'){ foo, bar }, ['bar', 'arg0']) # Calls bar('arg0'){ 'beep': foo, 'bloop': [bar, baz] }, ['beep', 'arg0']) # Calls foo('arg0'){ 'beep': foo, 'bloop': [bar, baz] }, ['bloop', 'bar', 'arg0']) # Calls bar('arg0')


Built-in converters handle int, float, bool, and pathlib.Path. Everything else is kept as a str.

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 funcli, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size funcli-0.1.2.tar.gz (3.3 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