package me.coley.recaf.command.impl;

import me.coley.recaf.command.completion.WorkspaceNameCompletions;
import me.coley.recaf.decompile.DecompileImpl;
import me.coley.recaf.decompile.Decompiler;
import picocli.CommandLine;

import java.util.*;
import java.util.concurrent.Callable;

/**
 * Command for decompiling a class in the workspace.
 *
 * @author Matt
 */
@CommandLine.Command(name = "decompile", description = "Decompile a class in the workspace.")
public class Decompile extends WorkspaceCommand implements Callable<String> {
	@CommandLine.Parameters(index = "0",  description = "The decompiler implementation to use.", arity = "0..1")
	public DecompileImpl decompiler = DecompileImpl.CFR;
	@CommandLine.Parameters(index = "1",  description = "The class to decompile",
			completionCandidates = WorkspaceNameCompletions.class)
	public String className;
	@CommandLine.Option(names = { "--options" },  description = "List of options to pass.", arity = "0..*")
	public Map<String, String> options = new HashMap<>();

	/**
	 * @return n/a
	 *
	 * @throws Exception
	 * 		<ul><li>IllegalStateException, cannot find class</li><li>Other, decompiler
	 * 		error</li></ul>
	 */
	@Override
	@SuppressWarnings("unchecked")
	public String call() throws Exception {
		if(className == null || className.isEmpty())
			throw new IllegalStateException("No class specified to decompile");
		if(!workspace.hasClass(className))
			throw new IllegalStateException("No class by the name '" + className +
					"' exists in the workspace");
		Decompiler<?> impl = decompiler.create();
		impl.getOptions().putAll((Map) options);
		return impl.decompile(workspace, className);
	}
}

@@ -547,32 +547,40 @@
 ine.
-Parameters(index = %220%22, 
+Option(names = %7B%22--decompiler%22%7D,
  des
@@ -634,22 +634,31 @@
 e.%22,
- arity = %220..1
+%0A%09%09%09defaultValue = %22CFR
 %22)%0A%09
@@ -748,9 +748,9 @@
  = %22
-1
+0
 %22,  

Change decompile command, decompiler is now an option instead of a parameter