#!/usr/bin/env python
""" Expose command line interfaces of modules in package. """
import os
import sys

COMMANDS = (
		('runexp', 'Run experiment: grammar extraction, parsing & evaluation.'),
		('fragments', 'Extract recurring fragments from treebanks.'),
		('eval', 'Evaluate discontinuous parse trees; similar to EVALB.'),
		('treetransforms', 'Apply tree transformations '
			'and convert between formats.'),
		('treedraw', 'Visualize (discontinuous) trees '),
		('grammar', 'Read off grammars from treebanks.'),
		('parser', 'Simple command line parser.'),
		('demos', 'Show some demonstrations of formalisms encoded in LCFRS.'),
		('gen', 'Generate sentences from a PLCFRS.'),
)

thiscmd = os.path.basename(sys.argv[0])
if len(sys.argv) <= 1 or sys.argv[1] not in dict(COMMANDS):
	print('usage: %s <command> [arguments]' % thiscmd)
	print('Command is one of:')
	for a, b in COMMANDS:
		print('  %s  %s' % (a.ljust(15), b))
	print('for additional instructions issue: %s <command> --help' % thiscmd)
else:
	cmd = sys.argv[1]
	sys.argv[0] = os.path.basename(sys.argv.pop(0)) + ' ' + cmd
	__import__('discodop.%s' % cmd, globals(), locals(), ['main']).main()
