package org.jf.baksmali;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import org.jf.baksmali.ListHelpCommand.ListHlepCommand;
import org.jf.util.jcommander.Command;
import org.jf.util.jcommander.ExtendedCommands;
import org.jf.util.jcommander.ExtendedParameters;
import javax.annotation.Nonnull;
import java.util.List;
@Parameters(commandDescription = "Lists various objects in a dex file.")
@ExtendedParameters(
commandName = "list",
commandAliases = "l")
public class ListCommand extends Command {
@Parameter(names = {"-h", "-?", "--help"}, help = true,
description = "Show usage information")
private boolean help;
public ListCommand(@Nonnull List<JCommander> commandAncestors) {
super(commandAncestors);
}
@Override protected void setupCommand(JCommander jc) {
List<JCommander> hierarchy = getCommandHierarchy();
ExtendedCommands.addExtendedCommand(jc, new ListStringsCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListMethodsCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListFieldsCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListTypesCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListClassesCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListDexCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListVtablesCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListFieldOffsetsCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListDependenciesCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListHelpCommand(hierarchy));
ExtendedCommands.addExtendedCommand(jc, new ListHlepCommand(hierarchy));
}
@Override public void run() {
JCommander jc = getJCommander();
if (help || jc.getParsedCommand() == null) {
usage();
return;
}
Command command = (Command)jc.getCommands().get(jc.getParsedCommand()).getObjects().get(0);
command.run();
}
}