package pl.polgrabia.demos.crackingcodeinterview.t16x8;

import java.util.ServiceLoader;

public class Program {

    public static void main(String[] args) {
        if (args.length != 1) {
            dump_help();
            System.exit(1);
            return;
        }

        String snr = args[0];
        int nr = Integer.parseInt(snr);
        var processorIterator = ServiceLoader.load(NumberDescriptionProcessor.class)
                .iterator();

        NumberDescriptionProcessor processor;
        while (processorIterator.hasNext()) {
            processor = processorIterator.next();
            processor.process(nr, System.out);
        }
    }

    private static void dump_help() {
        System.err.println("Usage: java Program <number>");
    }
}
