Search in sources :

Example 1 with FMVCLIConfig

use of org.fagu.fmv.cli.FMVCLIConfig in project fmv by f-agu.

the class Bootstrap method openFMVCLIConfig.

/**
 * @param conf
 * @return
 * @throws IOException
 */
private static FMVCLIConfig openFMVCLIConfig(String conf) throws IOException {
    File file = new File(conf);
    if (!file.exists()) {
        System.out.println("File not found: " + conf);
        return new FMVCLIConfig();
    }
    Properties properties = new Properties();
    InputStream inputStream = null;
    try {
        inputStream = new FileInputStream(file);
        properties.load(inputStream);
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
    return new FMVCLIConfig(properties);
}
Also used : FMVCLIConfig(org.fagu.fmv.cli.FMVCLIConfig) FileInputStream(java.io.FileInputStream) UnclosedInputStream(org.fagu.fmv.utils.io.UnclosedInputStream) InputStream(java.io.InputStream) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 2 with FMVCLIConfig

use of org.fagu.fmv.cli.FMVCLIConfig in project fmv by f-agu.

the class Bootstrap method main.

/**
 * @param args
 */
public static void main(String[] args) throws Exception {
    if (!FFMpeg.search().isFound()) {
        System.out.println("FFMpeg not found !");
        return;
    }
    if (!FFProbe.search().isFound()) {
        System.out.println("FFProbe not found !");
        return;
    }
    CommandLineParser parser = new GnuParser();
    Options options = new Options();
    options.addOption("c", "conf", true, "Conf properties");
    CommandLine commandLine = parser.parse(options, args);
    FMVCLIConfig fmvcliConfig;
    if (commandLine.hasOption('c')) {
        String conf = commandLine.getOptionValue('c');
        fmvcliConfig = openFMVCLIConfig(conf);
    } else {
        fmvcliConfig = new FMVCLIConfig();
    }
    System.out.println("FMV " + FMV.getVersion());
    System.out.println();
    Project project;
    String[] args2 = commandLine.getArgs();
    if (args2.length > 0) {
        project = loadProject(new File(args2[0]));
    } else {
        project = menu(System.out);
    }
    Console console = new Console(new Environnement(project, fmvcliConfig));
    console.run();
}
Also used : Options(org.apache.commons.cli.Options) Project(org.fagu.fmv.core.project.Project) CommandLine(org.apache.commons.cli.CommandLine) FMVCLIConfig(org.fagu.fmv.cli.FMVCLIConfig) GnuParser(org.apache.commons.cli.GnuParser) Console(org.fagu.fmv.cli.Console) Environnement(org.fagu.fmv.cli.Environnement) CommandLineParser(org.apache.commons.cli.CommandLineParser) File(java.io.File)

Aggregations

File (java.io.File)2 FMVCLIConfig (org.fagu.fmv.cli.FMVCLIConfig)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 GnuParser (org.apache.commons.cli.GnuParser)1 Options (org.apache.commons.cli.Options)1 Console (org.fagu.fmv.cli.Console)1 Environnement (org.fagu.fmv.cli.Environnement)1 Project (org.fagu.fmv.core.project.Project)1 UnclosedInputStream (org.fagu.fmv.utils.io.UnclosedInputStream)1