mirror of
https://github.com/revanced/smali.git
synced 2025-06-13 12:37:37 +02:00
Clean up how the usage messages are printed
This also fixes an OOM issue when trying to print the usage message on a terminal that doesn't report its width.
This commit is contained in:
@ -32,7 +32,7 @@ import org.apache.commons.cli.*;
|
||||
import org.jf.dexlib.Code.Opcode;
|
||||
import org.jf.dexlib.DexFile;
|
||||
import org.jf.util.ConsoleUtil;
|
||||
import org.jf.util.smaliHelpFormatter;
|
||||
import org.jf.util.SmaliHelpFormatter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -320,20 +320,16 @@ public class main {
|
||||
* Prints the usage message.
|
||||
*/
|
||||
private static void usage(boolean printDebugOptions) {
|
||||
smaliHelpFormatter formatter = new smaliHelpFormatter();
|
||||
formatter.setWidth(ConsoleUtil.getConsoleWidth());
|
||||
SmaliHelpFormatter formatter = new SmaliHelpFormatter();
|
||||
int consoleWidth = ConsoleUtil.getConsoleWidth();
|
||||
if (consoleWidth <= 0) {
|
||||
consoleWidth = 80;
|
||||
}
|
||||
|
||||
formatter.setWidth(consoleWidth);
|
||||
|
||||
formatter.printHelp("java -jar baksmali.jar [options] <dex-file>",
|
||||
"disassembles and/or dumps a dex file", basicOptions, "");
|
||||
|
||||
if (printDebugOptions) {
|
||||
System.out.println();
|
||||
System.out.println("Debug Options:");
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
formatter.renderOptions(sb, debugOptions);
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
"disassembles and/or dumps a dex file", basicOptions, printDebugOptions?debugOptions:null);
|
||||
}
|
||||
|
||||
private static void usage() {
|
||||
|
@ -37,14 +37,9 @@ import org.jf.dexlib.CodeItem;
|
||||
import org.jf.dexlib.DexFile;
|
||||
import org.jf.dexlib.Util.ByteArrayAnnotatedOutput;
|
||||
import org.jf.util.ConsoleUtil;
|
||||
import org.jf.util.smaliHelpFormatter;
|
||||
import org.jf.util.SmaliHelpFormatter;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
@ -347,20 +342,17 @@ public class main {
|
||||
* Prints the usage message.
|
||||
*/
|
||||
private static void usage(boolean printDebugOptions) {
|
||||
smaliHelpFormatter formatter = new smaliHelpFormatter();
|
||||
formatter.setWidth(ConsoleUtil.getConsoleWidth());
|
||||
SmaliHelpFormatter formatter = new SmaliHelpFormatter();
|
||||
|
||||
int consoleWidth = ConsoleUtil.getConsoleWidth();
|
||||
if (consoleWidth <= 0) {
|
||||
consoleWidth = 80;
|
||||
}
|
||||
|
||||
formatter.setWidth(consoleWidth);
|
||||
|
||||
formatter.printHelp("java -jar smali.jar [options] [--] [<smali-file>|folder]*",
|
||||
"assembles a set of smali files into a dex file", basicOptions, "");
|
||||
|
||||
if (printDebugOptions) {
|
||||
System.out.println();
|
||||
System.out.println("Debug Options:");
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
formatter.renderOptions(sb, debugOptions);
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
"assembles a set of smali files into a dex file", basicOptions, printDebugOptions?debugOptions:null);
|
||||
}
|
||||
|
||||
private static void usage() {
|
||||
|
@ -31,12 +31,17 @@ package org.jf.util;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
public class smaliHelpFormatter extends HelpFormatter {
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public void smaliHelpFormatter() {
|
||||
}
|
||||
|
||||
public void renderOptions(StringBuffer sb, Options options) {
|
||||
super.renderOptions(sb, getWidth(), options, getLeftPadding(), this.getDescPadding());
|
||||
public class SmaliHelpFormatter extends HelpFormatter {
|
||||
public void printHelp(String cmdLineSyntax, String header, Options options, Options debugOptions) {
|
||||
super.printHelp(cmdLineSyntax, header, options, "");
|
||||
if (debugOptions != null) {
|
||||
System.out.println();
|
||||
System.out.println("Debug Options:");
|
||||
PrintWriter pw = new PrintWriter(System.out);
|
||||
super.printOptions(pw, getWidth(), debugOptions, getLeftPadding(), getDescPadding());
|
||||
pw.flush();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user