home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (CommandLineInterfaceDriver.java)

This example Java source code file (CommandLineInterfaceDriver.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

argument, cmdlineexception, cmdlineparser, commandlineinterfacedriver, exception, logger, subcommand, subcommands

The CommandLineInterfaceDriver.java Java example source code

package org.deeplearning4j.cli.driver;


import org.deeplearning4j.cli.subcommands.Train;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.spi.SubCommand;
import org.kohsuke.args4j.spi.SubCommandHandler;
import org.kohsuke.args4j.spi.SubCommands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * CLI Driver for dl4j.
 *
 * Supports the train command
 *
 * @author Adam Gibson
 */
public class CommandLineInterfaceDriver {

	private static Logger log = LoggerFactory.getLogger(CommandLineInterfaceDriver.class);

	@Argument(required=true,index=0,metaVar="action",usage="subcommands, e.g., {train|test|predict}",handler=SubCommandHandler.class)
	@SubCommands({
			@SubCommand(name="train",impl=Train.class)
	})
	private org.deeplearning4j.cli.subcommands.SubCommand subCommand;



    /**
     * Print the usage for the command.
     */
	public static void printUsage() {
        System.out.println( "Usage: " );
		System.out.println( "\tdl4j [command] [params] " );
		System.out.println( "Commands: " );
		System.out.println( "\ttrain\tbuild a deep learning model " );
		System.out.println( "\ttest\ttest a deep learning model " );
		System.out.println( "\tpredict\tscore new records against a deep learning model " );
		System.out.println( "" );

	}

    public void doMain(String[] args) throws Exception {
        CmdLineParser parser = new CmdLineParser(this);
        try {
            parser.parseArgument(args);
            subCommand.execute();
        } catch( CmdLineException e ) {
            System.err.println(e.getMessage());
            printUsage();
            return;
        }
    }


    public static void main(String [] args) throws Exception {
        new CommandLineInterfaceDriver().doMain(args);

    }

}

Other Java examples (source code examples)

Here is a short list of links related to this Java CommandLineInterfaceDriver.java source code file:



my book on functional programming

 

new blog posts

 

Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.