001/*
002 * To change this license header, choose License Headers in Project Properties.
003 * To change this template file, choose Tools | Templates
004 * and open the template in the editor.
005 */
006package org.anarres.qemu.examples;
007
008import java.util.ArrayList;
009import java.util.Arrays;
010import java.util.List;
011import java.util.ServiceLoader;
012
013/**
014 *
015 * @author shevek
016 */
017public class Main {
018
019    public static void main(String[] args) throws Exception {
020        String name = args[0];
021        args = Arrays.copyOfRange(args, 1, args.length);
022
023        List<String> names = new ArrayList<String>();
024        for (QEmuExample example : ServiceLoader.load(QEmuExample.class)) {
025            if (name.equals(example.getClass().getSimpleName())) {
026                example.invoke(args);
027                return;
028            }
029            names.add(example.getClass().getSimpleName());
030        }
031        throw new IllegalArgumentException("No such example " + name + " in " + names);
032    }
033}