public static int run(int offset, String... args) throws Exception {
        if (args.length == offset + 1) {
            throw new RuntimeException("no <basedir> given");
        }
        File basedir = new File(args[offset + 1]);
        TipitakaUrlFactory urlFactory = new TipitakaUrlFactory(basedir);
        try {
            switch (Command.valueOf(args[offset + 0].toUpperCase().replace("-",
                    "_"))) {
                case MIRROR :
                    if (args.length == offset + 2) {
                        throw new RuntimeException(
                                "no <script> or <script,script> or ... given");
                    } else {
                        new TipitakaMirrorer(urlFactory).mirror(args[offset + 2]);
                        return 3;
                    }
                case INDEX :
                    if (args.length == offset + 2) {
                        throw new RuntimeException(
                                "no <script> or <script,script> or ... given");
                    } else {
                        new TipitakaSolrIndexer("http://localhost:8080/update", urlFactory)
                                .index(args[offset + 2]);
                        return 3;
                    }
                case DIRECTORY_STRUCTURE :
                    DirectoryStructure dir = new DirectoryStructure(urlFactory);
                    dir.reload();
                    dir.save(new File(basedir, "directory.map"));
                    return 2;
                case DIRECTORY_TRANSCRIBE:
                    if (args.length == offset + 2) {
                        throw new RuntimeException(
                                "no <script> or <script,script> or ... given");
                    } else {
                        dir = new DirectoryStructure(urlFactory);
                        dir.load(new File(basedir, "directory.map"));
                        Script script = dir.transcribe(args[offset + 2]);
                        script.save(new File(basedir, script.name + ".script"));
                        return 3;
                    }
                default :
                    showHelp();
                    return DONE;
            }
        } catch (IllegalArgumentException e) {
            showHelp();
            return DONE;
        }
    }