def main():
    try:
        version = 'CAMeL Tools v{}'.format(__version__)
        arguments = docopt(__doc__, version=version)
        if arguments['--list']:
            for scheme in _BUILTIN_SCHEMES:
                print('{}   {}'.format(scheme[0].ljust(20), scheme[1]))
            sys.exit(0)
        if (arguments['--scheme'] is not None):
            if (arguments['--scheme'] not in [s[0] for s in _BUILTIN_SCHEMES]):
                sys.stderr.write('Error: {} is not a valid scheme.\nRun `camel_transliterate -l` to see the list of available schemes.\n'.format(repr(arguments['--scheme'])))
                sys.exit(1)
            if (arguments['--marker'] is None):
                marker = '@@IGNORE@@'
            else:
                marker = arguments['--marker']
            ignore_markers = arguments['--ignore-markers']
            strip_markers = arguments['--strip-markers']
            (fin, fout) = _open_files(arguments['FILE'], arguments['--output'])
            try:
                mapper = CharMapper.builtin_mapper(arguments['--scheme'])
                trans = Transliterator(mapper, marker)
            except Exception:
                sys.stderr.write('Error: Could not load builtin scheme {}.\n'.format(repr(arguments['--scheme'])))
                sys.exit(1)
            try:
                for line in fin:
                    line = force_unicode(line)
                    if six.PY3:
                        fout.write(trans.transliterate(line, strip_markers, ignore_markers))
                    else:
                        fout.write(force_encoding(trans.transliterate(line, strip_markers, ignore_markers)))
                fout.flush()
            except Exception:
                sys.stderr.write('Error: An unkown error occured during transliteration.\n')
                sys.exit(1)
            if (arguments['FILE'] is not None):
                fin.close()
            if (arguments['--output'] is not None):
                fout.close()
        sys.exit(0)
    except KeyboardInterrupt:
        sys.stderr.write('Exiting...\n')
        sys.exit(1)
    except Exception:
        sys.stderr.write('Error: An unknown error occurred.\n')
        sys.exit(1)
def main():
    try:
        version = 'CAMeL Tools v{}'.format(__version__)
        arguments = docopt(__doc__, version=version)
        if arguments['--list']:
            for scheme in _BUILTIN_SCHEMES:
                print('{}   {}'.format(scheme[0].ljust(20), scheme[1]))
            sys.exit(0)
        if (arguments['--scheme'] is not None):
            if (arguments['--scheme'] not in [s[0] for s in _BUILTIN_SCHEMES]):
                sys.stderr.write('Error: {} is not a valid scheme.\nRun `camel_transliterate -l` to see the list of available schemes.\n'.format(repr(arguments['--scheme'])))
                sys.exit(1)
            if (arguments['--marker'] is None):
                marker = '@@IGNORE@@'
            else:
                marker = arguments['--marker']
            ignore_markers = arguments['--ignore-markers']
            strip_markers = arguments['--strip-markers']
            (fin, fout) = _open_files(arguments['FILE'], arguments['--output'])
            try:
                mapper = CharMapper.builtin_mapper(arguments['--scheme'])
                trans = Transliterator(mapper, marker)
            except Exception:
                sys.stderr.write('Error: Could not load builtin scheme {}.\n'.format(repr(arguments['--scheme'])))
                sys.exit(1)
            try:
                for line in fin:
                    line = force_unicode(line)
                    if six.PY3:
                        fout.write(trans.transliterate(line, strip_markers, ignore_markers))
                    else:
                        fout.write(force_encoding(trans.transliterate(line, strip_markers, ignore_markers)))
                fout.flush()
            except Exception:
                sys.stderr.write('Error: An unkown error occured during transliteration.\n')
                sys.exit(1)
            if (arguments['FILE'] is not None):
                fin.close()
            if (arguments['--output'] is not None):
                fout.close()
        sys.exit(0)
    except KeyboardInterrupt:
        sys.stderr.write('Exiting...\n')
        sys.exit(1)
    except Exception:
        sys.stderr.write('Error: An unknown error occurred.\n')
        sys.exit(1)