package com.shapesecurity.bandolier.es2017;

import com.shapesecurity.bandolier.es2017.bundlers.BundlerOptions;
import com.shapesecurity.bandolier.es2017.bundlers.PiercedModuleBundler;
import com.shapesecurity.bandolier.es2017.loader.FileLoader;
import com.shapesecurity.bandolier.es2017.loader.IResourceLoader;
import com.shapesecurity.bandolier.es2017.loader.NodeResolver;
import com.shapesecurity.shift.es2017.ast.Script;
import com.shapesecurity.shift.es2017.codegen.CodeGen;

import java.nio.file.Paths;

public class Main {
	public static void main(String[] args) throws Exception {
		if (args.length > 0) {
			IResourceLoader loader = new FileLoader();
			Script bundle = Bundler.bundle(BundlerOptions.NODE_OPTIONS, Paths.get(args[0]).toAbsolutePath(),
										   new NodeResolver(loader),
										   loader, new PiercedModuleBundler());
			System.out.println(CodeGen.codeGen(bundle));
		} else {
			System.err.println("Must provide a filename");
		}
	}
}

@@ -527,93 +527,992 @@
 n %7B%0A
-%09public static void main(String%5B%5D args) throws Exception %7B%0A%09%09if (args.length %3E 0) %7B%0A%09
+%0A%09private static final void usage() %7B%0A%09%09System.out.println(%22Arguments: %5BOPTIONS%5D %5Btarget module%5D%5Cn%22 +%0A%09%09%09%22Options:%5Cn%22 +%0A%09%09%09%22%09-n --node%09%09Node import resolution strategy%5Cn%22 +%0A%09%09%09%22%09-s --spec%09%09ECMAScript import resolution strategy%5Cn%22 +%0A%09%09%09%22%09-h --help%09%09Show this help menu%22);%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) throws Exception %7B%0A%09%09BundlerOptions options = BundlerOptions.DEFAULT_OPTIONS;%0A%09%09String filename = null;%0A%09%09for (String arg : args) %7B%0A%09%09%09if (arg.equals(%22-n%22) %7C%7C arg.equals(%22--node%22)) %7B%0A%09%09%09%09options = BundlerOptions.NODE_OPTIONS;%0A%09%09%09%7D else if (arg.equals(%22-s%22) %7C%7C arg.equals(%22--spec%22)) %7B%0A%09%09%09%09options = BundlerOptions.SPEC_OPTIONS;%0A%09%09%09%7D else if (arg.equals(%22-h%22) %7C%7C arg.equals(%22--help%22)) %7B%0A%09%09%09%09usage();%0A%09%09%09%09return;%0A%09%09%09%7D else if (filename == null) %7B%0A%09%09%09%09filename = arg;%0A%09%09%09%7D else %7B%0A%09%09%09%09System.err.println(%22Invalid argument: %22 + arg);%0A%09%09%09%09usage();%0A%09%09%09%09return;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09if (filename == null) %7B%0A%09%09%09System.err.println(%22No target module specified.%22);%0A%09%09%09usage();%0A%09%09%09return;%0A%09%09%7D%0A
 %09%09IR
@@ -1554,17 +1554,16 @@
 er();%0A%09%09
-%09
 Script b
@@ -1589,35 +1589,15 @@
 dle(
-BundlerOptions.NODE_OPTIONS
+options
 , Pa
@@ -1608,15 +1608,16 @@
 get(
-args%5B0%5D
+filename
 ).to
@@ -1632,17 +1632,16 @@
 Path(),%0A
-%09
 %09%09%09%09%09%09%09%09
@@ -1679,17 +1679,16 @@
 %09%09%09%09%09%09%09%09
-%09
    loade
@@ -1719,17 +1719,16 @@
 ler());%0A
-%09
 %09%09System
@@ -1770,73 +1770,8 @@
 ));%0A
-%09%09%7D else %7B%0A%09%09%09System.err.println(%22Must provide a filename%22);%0A%09%09%7D%0A
 %09%7D%0A%7D

add flags to Main