Sha256: c41ebbe0357338f2db52f7eecccfb1a5823623ff281dff674cc58aa3fa8f4a1a

Contents?: true

Size: 1.82 KB

Versions: 24

Compression:

Stored size: 1.82 KB

Contents

package org.embulk.cli;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class EmbulkArguments
{
    private EmbulkArguments(final EmbulkSubcommand subcommand, final List<String> subcommandArguments)
    {
        this.subcommand = subcommand;
        this.subcommandArguments = Collections.unmodifiableList(subcommandArguments);
    }

    public static EmbulkArguments extract(final List<String> arguments)
            throws EmbulkCommandLineException
    {
        final ArrayList<String> subcommandArguments = new ArrayList<String>();

        EmbulkSubcommand subcommand = null;
        for (final String argument : arguments) {
            if (subcommand == null && (!argument.startsWith("-"))) {
                subcommand = EmbulkSubcommand.of(argument);
            }
            else if (subcommand == null && (argument.equals("-b") || argument.equals("--bundle"))) {
                throw new EmbulkCommandLineException("\"-b\" or \"--bundle\" before a subcommand is not supported.");
            }
            else if (argument.equals("-version")) {
                return new EmbulkArguments(EmbulkSubcommand.VERSION_ERR, new ArrayList<String>());
            }
            else if (argument.equals("--version")) {
                return new EmbulkArguments(EmbulkSubcommand.VERSION_OUT, new ArrayList<String>());
            }
            else {
                subcommandArguments.add(argument);
            }
        }

        return new EmbulkArguments(subcommand, subcommandArguments);
    }

    public final EmbulkSubcommand getSubcommand()
    {
        return this.subcommand;
    }

    public final List<String> getSubcommandArguments()
    {
        return this.subcommandArguments;
    }

    private final EmbulkSubcommand subcommand;
    private final List<String> subcommandArguments;
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
embulk-0.8.39 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.39-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.38 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.38-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.37 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.37-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.36 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.36-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.35 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.35-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.34 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.34-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.33 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.33-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.32 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.32-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.31 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.31-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.30 embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
embulk-0.8.30-java embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java