package ch.tkuhn.nanolytics;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import net.trustyuri.TrustyUriUtils;

import org.nanopub.Nanopub;
import org.nanopub.NanopubImpl;
import org.nanopub.NanopubUtils;
import org.nanopub.extra.server.GetNanopub;
import org.openrdf.rio.RDFFormat;

public class Run {

	public static void main(String[] args) throws Exception {
		List<Nanopub> nanopubs = new ArrayList<>();
		for (String s : args) {
			if (s.matches("^https?://.*")) {
				nanopubs.add(new NanopubImpl(new URL(s)));
			} else if (TrustyUriUtils.isPotentialArtifactCode(s)) {
				nanopubs.add(GetNanopub.get(s));
			} else {
				nanopubs.add(new NanopubImpl(new File(s)));
			}
		}
		Run obj = new Run(nanopubs);
		obj.run();
	}

	private List<Nanopub> nanopubs = new ArrayList<>();

	public Run(List<Nanopub> nanopubs) {
		this.nanopubs.addAll(nanopubs);
	}

	public void run() throws Exception {
		for (Nanopub np : nanopubs) {
			NanopubUtils.writeToStream(np, System.out, RDFFormat.TRIG);
		}
	}

}

@@ -44,16 +44,44 @@
 o.File;%0A
+import java.io.IOException;%0A
 import j
@@ -179,24 +179,70 @@
 yUriUtils;%0A%0A
+import org.nanopub.MalformedNanopubException;%0A
 import org.n
@@ -389,148 +389,860 @@
 rdf.
-rio.RDFFormat;%0A%0Apublic class Run %7B%0A%0A%09public static void main(String%5B%5D args) throws Exception %7B%0A%09%09List%3CNanopub%3E nanopubs = new ArrayList%3C%3E();
+OpenRDFException;%0Aimport org.openrdf.rio.RDFFormat;%0A%0Aimport com.beust.jcommander.JCommander;%0Aimport com.beust.jcommander.ParameterException;%0A%0Apublic class Run %7B%0A%0A%09@com.beust.jcommander.Parameter(description = %22nanopubs%22, required = true)%0A%09private List%3CString%3E nanopubIdentifiers = new ArrayList%3CString%3E();%0A%0A%09public static void main(String%5B%5D args) throws IOException, OpenRDFException, MalformedNanopubException %7B%0A%09%09Run obj = new Run();%0A%09%09JCommander jc = new JCommander(obj);%0A%09%09try %7B%0A%09%09%09jc.parse(args);%0A%09%09%7D catch (ParameterException ex) %7B%0A%09%09%09jc.usage();%0A%09%09%09System.exit(1);%0A%09%09%7D%0A%09%09try %7B%0A%09%09%09obj.init();%0A%09%09%09obj.run();%0A%09%09%7D catch (Exception ex) %7B%0A%09%09%09ex.printStackTrace();%0A%09%09%09System.exit(1);%0A%09%09%7D%0A%09%7D%0A%0A%09private List%3CNanopub%3E nanopubs = new ArrayList%3C%3E();%0A%0A%09public Run() %7B%0A%09%7D%0A%0A%09private void init() throws IOException, OpenRDFException, MalformedNanopubException %7B
 %0A%09%09f
@@ -1256,19 +1256,33 @@
 ing s : 
-arg
+nanopubIdentifier
 s) %7B%0A%09%09%09
@@ -1530,182 +1530,8 @@
 %09%09%7D%0A
-%09%09Run obj = new Run(nanopubs);%0A%09%09obj.run();%0A%09%7D%0A%0A%09private List%3CNanopub%3E nanopubs = new ArrayList%3C%3E();%0A%0A%09public Run(List%3CNanopub%3E nanopubs) %7B%0A%09%09this.nanopubs.addAll(nanopubs);%0A
 %09%7D%0A%0A
@@ -1556,16 +1556,36 @@
  throws 
+IOException, OpenRDF
 Exceptio

Use JCommander