From 793df05b2fb06a083a440eff7e5df36434a3df11 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Wed, 6 Feb 2019 14:59:31 +0800 Subject: [PATCH] add pwd command. #493 --- .../core/command/BuiltinCommandPack.java | 2 ++ .../core/command/basic1000/PwdCommand.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 core/src/main/java/com/taobao/arthas/core/command/basic1000/PwdCommand.java diff --git a/core/src/main/java/com/taobao/arthas/core/command/BuiltinCommandPack.java b/core/src/main/java/com/taobao/arthas/core/command/BuiltinCommandPack.java index f9693c45..20d0b724 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/BuiltinCommandPack.java +++ b/core/src/main/java/com/taobao/arthas/core/command/BuiltinCommandPack.java @@ -4,6 +4,7 @@ import com.taobao.arthas.core.command.basic1000.ClsCommand; import com.taobao.arthas.core.command.basic1000.HelpCommand; import com.taobao.arthas.core.command.basic1000.HistoryCommand; import com.taobao.arthas.core.command.basic1000.KeymapCommand; +import com.taobao.arthas.core.command.basic1000.PwdCommand; import com.taobao.arthas.core.command.basic1000.ResetCommand; import com.taobao.arthas.core.command.basic1000.SessionCommand; import com.taobao.arthas.core.command.basic1000.ShutdownCommand; @@ -85,5 +86,6 @@ public class BuiltinCommandPack implements CommandResolver { commands.add(Command.create(SystemPropertyCommand.class)); commands.add(Command.create(SystemEnvCommand.class)); commands.add(Command.create(HistoryCommand.class)); + commands.add(Command.create(PwdCommand.class)); } } diff --git a/core/src/main/java/com/taobao/arthas/core/command/basic1000/PwdCommand.java b/core/src/main/java/com/taobao/arthas/core/command/basic1000/PwdCommand.java new file mode 100644 index 00000000..d5a59e72 --- /dev/null +++ b/core/src/main/java/com/taobao/arthas/core/command/basic1000/PwdCommand.java @@ -0,0 +1,18 @@ +package com.taobao.arthas.core.command.basic1000; + +import java.io.File; + +import com.taobao.arthas.core.shell.command.AnnotatedCommand; +import com.taobao.arthas.core.shell.command.CommandProcess; +import com.taobao.middleware.cli.annotations.Name; +import com.taobao.middleware.cli.annotations.Summary; + +@Name("pwd") +@Summary("Return working directory name") +public class PwdCommand extends AnnotatedCommand { + @Override + public void process(CommandProcess process) { + process.write(new File("").getAbsolutePath()).write("\n"); + process.end(); + } +}