Search in sources :

Example 6 with FileType

use of org.fagu.fmv.media.FileType in project fmv by f-agu.

the class List method getFilter.

// *************************************************
/**
 * @param args
 * @return
 */
private Predicate<FileSource> getFilter(String[] args) {
    CommandLine cmdLine = parse(args);
    Predicate<FileSource> predicate = null;
    for (final FileType fileType : FileType.values()) {
        String name = fileType.name().toLowerCase();
        if (cmdLine.hasOption(name)) {
            Predicate<FileSource> tmp = fs -> fileType == fs.getFileType();
            predicate = predicate == null ? tmp : predicate.or(tmp);
        }
    }
    if (predicate == null) {
        return s -> true;
    }
    return predicate;
}
Also used : Command(org.fagu.fmv.cli.annotation.Command) Alias(org.fagu.fmv.cli.annotation.Alias) Predicate(java.util.function.Predicate) FileSource(org.fagu.fmv.core.project.FileSource) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) ConsoleOutput(org.fagu.fmv.cli.ConsoleOutput) Aliases(org.fagu.fmv.cli.annotation.Aliases) FileType(org.fagu.fmv.media.FileType) CommandLine(org.apache.commons.cli.CommandLine) FileType(org.fagu.fmv.media.FileType) FileSource(org.fagu.fmv.core.project.FileSource)

Example 7 with FileType

use of org.fagu.fmv.media.FileType in project fmv by f-agu.

the class List method getOptions.

/**
 * @see org.fagu.fmv.cli.command.AbstractCommand#getOptions()
 */
@Override
public Options getOptions() {
    Options options = super.getOptions();
    for (FileType fileType : FileType.values()) {
        String name = fileType.name().toLowerCase();
        options.addOption(Character.toString(name.charAt(0)), name, false, "");
    }
    return options;
}
Also used : Options(org.apache.commons.cli.Options) FileType(org.fagu.fmv.media.FileType)

Aggregations

FileType (org.fagu.fmv.media.FileType)7 Element (org.dom4j.Element)3 File (java.io.File)2 Options (org.apache.commons.cli.Options)2 IOException (java.io.IOException)1 Optional (java.util.Optional)1 SortedSet (java.util.SortedSet)1 TreeMap (java.util.TreeMap)1 Predicate (java.util.function.Predicate)1 CommandLine (org.apache.commons.cli.CommandLine)1 DocumentException (org.dom4j.DocumentException)1 ConsoleOutput (org.fagu.fmv.cli.ConsoleOutput)1 Alias (org.fagu.fmv.cli.annotation.Alias)1 Aliases (org.fagu.fmv.cli.annotation.Aliases)1 Command (org.fagu.fmv.cli.annotation.Command)1 FileSource (org.fagu.fmv.core.project.FileSource)1 AudioStream (org.fagu.fmv.ffmpeg.metadatas.AudioStream)1 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)1 VideoStream (org.fagu.fmv.ffmpeg.metadatas.VideoStream)1 ImageMetadatas (org.fagu.fmv.im.ImageMetadatas)1