/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.pdfbox.tools;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.concurrent.Callable;

import org.apache.pdfbox.io.MemoryUsageSetting;
import org.apache.pdfbox.multipdf.PDFMergerUtility;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;

/**
 * This is the main program that will take a list of pdf documents and merge them,
 * saving the result in a new document.
 *
 * @author Ben Litchfield
 */
@Command(name = "pdfmerger", description = "Merges multiple PDF documents into one", versionProvider = Version.class, mixinStandardHelpOptions = true)
public final class PDFMerger implements Callable<Integer>
{
    // Expected for CLI app to write to System.out/Sytem.err
    @SuppressWarnings("squid:S106")
    private static final PrintStream SYSERR = System.err;

    @Parameters(paramLabel = "inputfile", index="0", arity = "2..*", description = "the PDF files to merge.")
    private File[] infiles;

    @Parameters(paramLabel = "outputfile", index="1", arity="1", description = "the merged PDF file.")
    private File outfile;

    /**
     * Infamous main method.
     *
     * @param args Command line arguments, should be at least 3.
     */
    public static void main( String[] args )
    {
        // suppress the Dock icon on OS X
        System.setProperty("apple.awt.UIElement", "true");

        int exitCode = new CommandLine(new PDFMerger()).execute(args);
        System.exit(exitCode);
    }

    public Integer call()
    {
        PDFMergerUtility merger = new PDFMergerUtility();

        try
        {
            for (File infile : infiles)
            {
                merger.addSource(infile);
            }

            merger.setDestinationFileName(outfile.getAbsolutePath());
            merger.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
        }
        catch (IOException ioe)
        {
            SYSERR.println( "Error merging documents: " + ioe.getMessage());
            return 4;
        }
        return 0;
    }
}

@@ -1111,16 +1111,51 @@
 ommand;%0A
+import picocli.CommandLine.Option;%0A
 import p
@@ -1722,205 +1722,192 @@
    @
-Parameters(paramLabel = %22inputfile%22, index=%220%22, arity = %222..*%22, description = %22the PDF files to merge.%22)%0A    private File%5B%5D infiles;%0A%0A    @Parameters(paramLabel = %22outputfile%22, index=%221%22, arity=%221%22
+Option(names = %7B%22-i%22, %22--input%22%7D, description = %22the PDF files to merge.%22, paramLabel = %22%3Cinfile%3E%22, required = true)%0A    private File%5B%5D infiles;%0A%0A    @Option(names = %7B%22-o%22, %22--output%22%7D
 , de
@@ -1940,16 +1940,33 @@
 F file.%22
+, required = true
 )%0A    pr

use options instead of parameters as suggested by clig.dev