package cz.hobrasoft.pdfmu;

import net.sourceforge.argparse4j.impl.Arguments;
import net.sourceforge.argparse4j.inf.Subparser;
import net.sourceforge.argparse4j.inf.Subparsers;

/**
 * Gets or sets the version of a PDF file
 * 
 * <p>
 * Usage:
 * <ul>
 * <li>{@code pdfmu version --in in.pdf --out out.pdf --set 1.6}</li>
 * <li>{@code pdfmu version --in in.pdf --get}</li>
 * <li>{@code pdfmu version inout.pdf --force}</li>
 * </ul>
 * 
 * @author <a href="mailto:filip.bartek@hobrasoft.cz">Filip Bartek</a>
 */
public class CommandVersion implements Command {

    @Override
    public void execute(String[] args) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Subparser addParser(Subparsers subparsers) {
        String help = "Set or display version of a PDF document";
        
        Subparser subparser = subparsers.addParser("version")
                .help(help)
                .description(help)
                .defaultHelp(true)
                .setDefault("command", CommandVersion.class);
        subparser.addArgument("-i", "--in")
                .type(String.class)
                // TODO: Consider using `FileInputStream.class` as type
                // http://argparse4j.sourceforge.net/usage.html#argument-nargs
                // Also see:
                // http://argparse4j.sourceforge.net/usage.html#filetype
                .help("input PDF document")
                .required(true)
                .nargs("?");
        subparser.addArgument("-o", "--out")
                .type(String.class)
                .help("output PDF document")
                .nargs("?");
        subparser.addArgument("-s", "--set")
                .type(String.class)
                .help("PDF version to set")
                .nargs("?")
                .setDefault("1.6");
        subparser.addArgument("-g", "--get")
                .type(boolean.class)
                .help("display version of IN without setting the version")
                .action(Arguments.storeTrue());
        subparser.addArgument("--force")
                .help("overwrite OUT if already present")
                .type(boolean.class)
                .action(Arguments.storeTrue());
        
        return subparser;
    }
    
}

@@ -828,16 +828,131 @@
 ument%22;%0A
+        String metavarIn = %22IN.pdf%22;%0A        String metavarOut = %22OUT.pdf%22;%0A        String metavarSet = %22VERSION%22;%0A
         
@@ -1602,32 +1602,68 @@
      .nargs(%22?%22)
+%0A                .metavar(metavarIn)
 ;%0A        subpar
@@ -1801,16 +1801,53 @@
 rgs(%22?%22)
+%0A                .metavar(metavarOut)
 ;%0A      
@@ -1947,28 +1947,58 @@
 elp(
-%22PDF version to set%22
+String.format(%22set PDF version to %25s%22, metavarSet)
 )%0A  
@@ -2057,16 +2057,53 @@
 t(%221.6%22)
+%0A                .metavar(metavarSet)
 ;%0A      
@@ -2200,16 +2200,30 @@
   .help(
+String.format(
 %22display
@@ -2234,18 +2234,18 @@
 sion of 
-IN
+%25s
  without
@@ -2257,32 +2257,44 @@
 ing the version%22
+, metavarIn)
 )%0A              
@@ -2390,16 +2390,30 @@
   .help(
+String.format(
 %22overwri
@@ -2415,19 +2415,18 @@
 erwrite 
-OUT
+%25s
  if alre
@@ -2433,24 +2433,37 @@
 ady present%22
+, metavarOut)
 )%0A          

Update parser metavar names