mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
fix grep command --trim-end support
This commit is contained in:
@@ -10,8 +10,6 @@ import com.taobao.middleware.cli.annotations.Name;
|
||||
import com.taobao.middleware.cli.annotations.Option;
|
||||
import com.taobao.middleware.cli.annotations.Summary;
|
||||
|
||||
import one.profiler.AsyncProfiler;
|
||||
|
||||
/**
|
||||
* @see com.taobao.arthas.core.shell.command.internal.GrepHandler
|
||||
*/
|
||||
@@ -93,9 +91,9 @@ public class GrepCommand extends AnnotatedCommand {
|
||||
this.showLineNumber = showLineNumber;
|
||||
}
|
||||
|
||||
@Option(longName = "trim-end", flag = true)
|
||||
@Option(longName = "trim-end", flag = false)
|
||||
@DefaultValue("true")
|
||||
@Description("Remove whitespaces at the end of the line")
|
||||
@Description("Remove whitespaces at the end of the line, default value true")
|
||||
public void setTrimEnd(boolean trimEnd) {
|
||||
this.trimEnd = trimEnd;
|
||||
}
|
||||
@@ -170,11 +168,7 @@ public class GrepCommand extends AnnotatedCommand {
|
||||
|
||||
@Override
|
||||
public void process(CommandProcess process) {
|
||||
process.write("The grep command only for pipes. See 'grep --help'").write("\n");
|
||||
|
||||
String libPath = "/private/tmp/async-profiler-1.6-macos-x64/build/libasyncProfiler.so";
|
||||
AsyncProfiler instance = AsyncProfiler.getInstance(libPath);
|
||||
process.write(instance.toString());
|
||||
process.write("The grep command only for pipes. See 'grep --help'\n");
|
||||
process.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,12 +46,16 @@ public class GrepHandler extends StdoutHandler {
|
||||
*/
|
||||
private final Integer maxCount;
|
||||
|
||||
private static CLI cli = null;
|
||||
|
||||
public static StdoutHandler inject(List<CliToken> tokens) {
|
||||
List<String> args = StdoutHandler.parseArgs(tokens, NAME);
|
||||
|
||||
GrepCommand grepCommand = new GrepCommand();
|
||||
CLI cli = CLIConfigurator.define(GrepCommand.class);
|
||||
CommandLine commandLine = cli.parse(args);
|
||||
if (cli == null) {
|
||||
cli = CLIConfigurator.define(GrepCommand.class);
|
||||
}
|
||||
CommandLine commandLine = cli.parse(args, true);
|
||||
|
||||
try {
|
||||
CLIConfigurator.inject(commandLine, grepCommand);
|
||||
|
||||
Reference in New Issue
Block a user