mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
transform command: echo, version
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.taobao.arthas.core.command.basic1000;
|
||||
|
||||
import com.taobao.arthas.core.command.Constants;
|
||||
import com.taobao.arthas.core.command.model.EchoModel;
|
||||
import com.taobao.arthas.core.command.model.MessageModel;
|
||||
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.middleware.cli.annotations.Argument;
|
||||
@@ -30,8 +32,7 @@ public class EchoCommand extends AnnotatedCommand {
|
||||
@Override
|
||||
public void process(CommandProcess process) {
|
||||
if (message != null) {
|
||||
process.write(message);
|
||||
process.write("\n");
|
||||
process.appendResult(new EchoModel(message));
|
||||
}
|
||||
|
||||
process.end();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.taobao.arthas.core.command.basic1000;
|
||||
|
||||
|
||||
import com.taobao.arthas.core.command.model.VersionModel;
|
||||
import com.taobao.arthas.core.shell.command.AnnotatedCommand;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
import com.taobao.arthas.core.util.ArthasBanner;
|
||||
@@ -15,8 +16,13 @@ import com.taobao.middleware.cli.annotations.Summary;
|
||||
@Name("version")
|
||||
@Summary("Display Arthas version")
|
||||
public class VersionCommand extends AnnotatedCommand {
|
||||
|
||||
@Override
|
||||
public void process(CommandProcess process) {
|
||||
process.write(ArthasBanner.version()).write("\n").end();
|
||||
VersionModel result = new VersionModel();
|
||||
result.setVersion(ArthasBanner.version());
|
||||
process.appendResult(result);
|
||||
process.end();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/5/11
|
||||
*/
|
||||
public class EchoModel extends ResultModel {
|
||||
|
||||
private String content;
|
||||
|
||||
public EchoModel() {
|
||||
}
|
||||
|
||||
public EchoModel(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "echo";
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.taobao.arthas.core.command.model;
|
||||
|
||||
public class VersionModel extends ResultModel {
|
||||
|
||||
private String version;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "version";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.EchoModel;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/5/11
|
||||
*/
|
||||
public class EchoView extends ResultView<EchoModel> {
|
||||
@Override
|
||||
public void draw(CommandProcess process, EchoModel result) {
|
||||
process.write(result.getContent()).write("\n");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.taobao.arthas.core.command.view;
|
||||
|
||||
import com.taobao.arthas.core.command.model.VersionModel;
|
||||
import com.taobao.arthas.core.shell.command.CommandProcess;
|
||||
|
||||
/**
|
||||
* @author gongdewei 2020/3/27
|
||||
*/
|
||||
public class VersionView extends ResultView<VersionModel> {
|
||||
|
||||
@Override
|
||||
public void draw(CommandProcess process, VersionModel result) {
|
||||
writeln(process, result.getVersion());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user