mirror of
https://github.com/alibaba/arthas.git
synced 2026-11-30 15:33:59 +00:00
jad command support --source-only option. #496
This commit is contained in:
1 parent
c18bd53ed5
commit
c4751931ce
1 file changed
+19
@@ -40,6 +40,7 @@ import static com.taobao.text.ui.Element.label;
|
|||||||
@Description(Constants.EXAMPLE +
|
@Description(Constants.EXAMPLE +
|
||||||
" jad java.lang.String\n" +
|
" jad java.lang.String\n" +
|
||||||
" jad java.lang.String toString\n" +
|
" jad java.lang.String toString\n" +
|
||||||
|
" jad --source-only java.lang.String\n" +
|
||||||
" jad -c 39eb305e org/apache/log4j/Logger\n" +
|
" jad -c 39eb305e org/apache/log4j/Logger\n" +
|
||||||
" jad -c 39eb305e -E org\\\\.apache\\\\.*\\\\.StringUtils\n" +
|
" jad -c 39eb305e -E org\\\\.apache\\\\.*\\\\.StringUtils\n" +
|
||||||
Constants.WIKI + Constants.WIKI_HOME + "jad")
|
Constants.WIKI + Constants.WIKI_HOME + "jad")
|
||||||
@@ -52,6 +53,11 @@ public class JadCommand extends AnnotatedCommand {
|
|||||||
private String code = null;
|
private String code = null;
|
||||||
private boolean isRegEx = false;
|
private boolean isRegEx = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* jad output source code only
|
||||||
|
*/
|
||||||
|
private boolean sourceOnly = false;
|
||||||
|
|
||||||
@Argument(argName = "class-pattern", index = 0)
|
@Argument(argName = "class-pattern", index = 0)
|
||||||
@Description("Class name pattern, use either '.' or '/' as separator")
|
@Description("Class name pattern, use either '.' or '/' as separator")
|
||||||
public void setClassPattern(String classPattern) {
|
public void setClassPattern(String classPattern) {
|
||||||
@@ -77,6 +83,12 @@ public class JadCommand extends AnnotatedCommand {
|
|||||||
isRegEx = regEx;
|
isRegEx = regEx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Option(longName = "source-only", flag = true)
|
||||||
|
@Description("Output source code only")
|
||||||
|
public void setSourceOnly(boolean sourceOnly) {
|
||||||
|
this.sourceOnly = sourceOnly;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(CommandProcess process) {
|
public void process(CommandProcess process) {
|
||||||
RowAffect affect = new RowAffect();
|
RowAffect affect = new RowAffect();
|
||||||
@@ -97,7 +109,9 @@ public class JadCommand extends AnnotatedCommand {
|
|||||||
processExactMatch(process, affect, inst, matchedClasses, withInnerClasses);
|
processExactMatch(process, affect, inst, matchedClasses, withInnerClasses);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
if (!this.sourceOnly) {
|
||||||
process.write(affect + "\n");
|
process.write(affect + "\n");
|
||||||
|
}
|
||||||
process.end();
|
process.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,6 +134,11 @@ public class JadCommand extends AnnotatedCommand {
|
|||||||
source = "unknown";
|
source = "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.sourceOnly) {
|
||||||
|
process.write(LangRenderUtil.render(source) + "\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
process.write("\n");
|
process.write("\n");
|
||||||
process.write(RenderUtil.render(new LabelElement("ClassLoader: ").style(Decoration.bold.fg(Color.red)), process.width()));
|
process.write(RenderUtil.render(new LabelElement("ClassLoader: ").style(Decoration.bold.fg(Color.red)), process.width()));
|
||||||
|
|||||||
Reference in new issue
Block a user