Преглед на файлове

Snippets command

master
Chris Smith преди 15 години
родител
ревизия
af2fe20147
променени са 1 файла, в които са добавени 39 реда и са изтрити 0 реда
  1. 39
    0
      src/com/md87/charliebravo/commands/SnippetsCommand.java

+ 39
- 0
src/com/md87/charliebravo/commands/SnippetsCommand.java Целия файл

@@ -0,0 +1,39 @@
1
+/*
2
+ * To change this template, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+
6
+package com.md87.charliebravo.commands;
7
+
8
+import com.md87.charliebravo.Command;
9
+import com.md87.charliebravo.InputHandler;
10
+import com.md87.charliebravo.Response;
11
+
12
+/**
13
+ *
14
+ * @author chris
15
+ */
16
+public class SnippetsCommand implements Command {
17
+
18
+    public void execute(InputHandler handler, Response response, String line) throws Exception {
19
+        final StringBuilder builder = new StringBuilder();
20
+
21
+        for (String snipp : handler.getSnippets(response.getTarget()).getList()) {
22
+            if (builder.length() > 0) {
23
+                builder.append(", ");
24
+            }
25
+
26
+            builder.append(snipp);
27
+        }
28
+        
29
+        response.setInheritFollows(true);
30
+
31
+        if (builder.length() == 0) {
32
+            response.sendMessage("There are no detected snippets", true);
33
+        } else {
34
+            response.sendMessage("the following snippets are currently registered: "
35
+                    + builder.toString());
36
+        }
37
+    }
38
+
39
+}

Loading…
Отказ
Запис