package org.aktin.broker.client.live.runquery;




public class CLI  {


	private static void printUsage() {
		System.err.println("Usage: "+CLI.class.getPackageName()+"."+CLI.class.getName()+" [-waitfor=N] -broker=BROKERURI [-auth=CLASS,PARAM] MEDIATYPE1=INPUT1 [...]");
		System.err.println(" -waitfor specifies the number of nodes to wait for. defaults to -1 meaning all nodes currently known.");
		System.err.println(" -broker specifies the broker endpoint URI e.g. http://localhost:8080/broker/");
		System.err.println(" -auth: use authentication class and param. e.g. org.aktin.broker.client2.auth.ApiKeyAuthentication,xxxApiKey123");
		System.err.println(" MEDIATYPE1=INPUT1: request definition to publish. if only one type is specified, INPUT1 can be '-' to read from stdin. Otherwise INPUT1 should indicate a file containing the definition");		
	}

	public static void main(String[] args) {
		printUsage();
		throw new UnsupportedOperationException("Just a stub. Not implemented. Come back later.");
	}
}

@@ -45,69 +45,764 @@
 y;%0A%0A
-%0A%0A%0Apublic class CLI  %7B%0A%0A%0A%09private static void printUsage() %7B%0A
+import java.io.IOException;%0Aimport java.net.URI;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Paths;%0A%0Aimport org.aktin.broker.client.live.BrokerConfiguration;%0Aimport org.aktin.broker.client2.BrokerAdmin2;%0A%0Aimport lombok.AllArgsConstructor;%0Aimport lombok.Getter;%0A%0Apublic class CLI  %7B%0A%09private BrokerAdmin2 admin;%0A%0A%09private static void printUsage() %7B%0A%09%09System.err.println(%22Usage: %22+CLI.class.getPackageName()+%22.%22+CLI.class.getName()+%22 %3CBROKER_ENDPOINT_URI%3E %3CAuthFilterImplementationClass%3E %3CAuthFilterArgument%3E %3CRequestMediaType%3E %3CRequestFileName%3E%22);%0A%09%09System.err.println(%22e.g.: %22+CLI.class.getPackageName()+%22.%22+CLI.class.getName()+%22 http://localhost:8080/broker/ org.aktin.broker.client2.auth.ApiKeyAuthentication xxxAdmin1234 text/sql query.sql%22);%09%09%09%0A//
 %09%09Sy
@@ -955,24 +955,26 @@
 T1 %5B...%5D%22);%0A
+//
 %09%09System.err
@@ -1085,24 +1085,26 @@
 y known.%22);%0A
+//
 %09%09System.err
@@ -1190,24 +1190,26 @@
 /broker/%22);%0A
+//
 %09%09System.err
@@ -1330,24 +1330,26 @@
 piKey123%22);%0A
+//
 %09%09System.err
@@ -1558,157 +1558,993 @@
 %7D%0A%0A%09
-public static void main(String%5B%5D args) %7B%0A%09%09printUsage();%0A%09%09throw new UnsupportedOperationException(%22Just a stub. Not implemented. Come back later.%22);
+@Getter%0A%09@AllArgsConstructor%0A%09public static class Config implements BrokerConfiguration%7B%0A%09%09private URI brokerEndpointURI;%0A%09%09private String authClass;%0A%09%09private String authParam;%09%09%0A%09%7D%0A%09public void runQuery(String mediaType, String requestContent) throws IOException %7B%0A%09%09int rid = admin.createRequest(mediaType, requestContent);%0A%09%09admin.publishRequest(rid);%0A%09%09System.out.println(%22Request created and published: %22+rid);%0A%09%7D%0A%09public static void main(String%5B%5D args) %7B%0A%09%09if( args.length != 5 ) %7B%0A%09%09%09printUsage();%0A%09%09%09return;%0A%09%09%7D%0A%09%09String mediaType = args%5B3%5D;%0A%0A%09%09Config config = new Config(URI.create(args%5B0%5D), args%5B1%5D, args%5B2%5D);%0A%09%09BrokerAdmin2 admin = new BrokerAdmin2(config.getBrokerEndpointURI());%0A%09%09admin.setAuthFilter(config.instantiateAuthFilter());%0A%0A%09%09CLI cli = new CLI();%0A%09%09cli.admin = admin;%0A%09%09try %7B%0A%09%09%09String requestContent = Files.readString(Paths.get(args%5B4%5D));%0A%09%09%09cli.runQuery(mediaType, requestContent);%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%09System.exit(-1);%0A%09%09%7D
 %0A%09%7D%0A

add CLI to submit queries