package picocli.examples.parseresult;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import picocli.CommandLine.ParseResult;
import picocli.CommandLine.Spec;

import java.util.List;

@Command(name = "myapp", mixinStandardHelpOptions = true, version = "myapp 0.1")
public class ParseResultDemo implements Runnable {
    @Spec CommandSpec spec;

    @Option(names = "-x")
    int x;

    @Parameters
    List<String> positionalParams;

    @Override
    public void run() {
        ParseResult parseResult = spec.commandLine().getParseResult();

        System.out.println(parseResult.expandedArgs());
        System.out.println(parseResult.originalArgs());
    }

    public static void main(String[] args) {
        new CommandLine(new ParseResultDemo()).execute(args);
    }
}

@@ -510,16 +510,80 @@
    int x
+ = 10;%0A%0A    @Option(names = %22-y%22, defaultValue = %2220%22)%0A    int y
 ;%0A%0A    @
@@ -688,26 +688,17 @@
 Result p
-arseResult
+r
  = spec.
@@ -758,26 +758,17 @@
 rintln(p
-arseResult
+r
 .expande
@@ -809,33 +809,587 @@
 ln(p
-arseResult.originalArgs()
+r.originalArgs());%0A%0A        String%5B%5D options = %7B%22x%22, %22y%22%7D;%0A        for (String name : options) %7B%0A            System.out.printf(%22%25s was specified: %25s%25n%22, name, pr.hasMatchedOption(name));%0A            System.out.printf(%22%25s=%25s (-1 means this option was not matched on command line)%25n%22, name, pr.matchedOptionValue(%22x%22, -1));%0A            System.out.printf(%22%25s=%25s (arg value or default)%25n%22, name, spec.findOption(name).getValue());%0A            System.out.println();%0A        %7D%0A%0A        System.out.printf(%22-x=%25s (field value)%25n%22, x);%0A        System.out.printf(%22-y=%25s (field value)%25n%22, y
 );%0A 

Update example for accessing args from application