feat: init commit

This commit is contained in:
2025-05-02 22:12:59 +08:00
parent fa9935f3e4
commit 2736ce2263
4 changed files with 140 additions and 53 deletions

View File

@@ -0,0 +1,38 @@
package me.hatter.demo;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import java.io.File;
@Command(name = "example",
mixinStandardHelpOptions = true,
version = "Picocli example 1.0")
public class PicocliCli {
@Option(names = {"-v", "--verbose"},
description = "Verbose mode. Helpful for troubleshooting. Multiple -v options increase the verbosity.")
private boolean[] verbose = new boolean[0];
@Parameters(arity = "1..*", paramLabel = "FILE", description = "File(s) to process.")
private File[] inputFiles;
public void run() {
if (verbose.length > 0) {
System.out.println(inputFiles.length + " files to process...");
}
if (verbose.length > 1) {
for (File f : inputFiles) {
System.out.println(f.getAbsolutePath());
}
}
}
public static void main(String[] args) {
// By implementing Runnable or Callable, parsing, error handling and handling user
// requests for usage help or version help can be done with one line of code.
int exitCode = new CommandLine(new PicocliCli()).execute(args);
System.exit(exitCode);
}
}