Pārlūkot izejas kodu

Chat and global commands

tags/0.6.3m1rc1
Chris Smith 15 gadus atpakaļ
vecāks
revīzija
76ca1ed8e0

+ 4
- 3
src/com/dmdirc/commandparser/commands/chat/Me.java Parādīt failu

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.chat;
24 24
 
25 25
 import com.dmdirc.MessageTarget;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.commands.ChatCommand;
28 29
 import com.dmdirc.commandparser.CommandManager;
29 30
 import com.dmdirc.commandparser.commands.ValidatingCommand;
@@ -48,11 +49,11 @@ public final class Me extends ChatCommand implements ValidatingCommand {
48 49
     /** {@inheritDoc} */
49 50
     @Override
50 51
     public void execute(final InputWindow origin, final Server server,
51
-            final MessageTarget target, final boolean isSilent, final String... args) {
52
-        if (args.length == 0) {
52
+            final MessageTarget target, final boolean isSilent, final CommandArguments args) {
53
+        if (args.getArguments().length == 0) {
53 54
             showUsage(origin, isSilent, "me", "<action>");
54 55
         } else {
55
-            target.sendAction(implodeArgs(args));
56
+            target.sendAction(args.getArgumentsAsString());
56 57
         }
57 58
     }
58 59
     

+ 3
- 2
src/com/dmdirc/commandparser/commands/global/Active.java Parādīt failu

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Main;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -50,8 +51,8 @@ public final class Active extends GlobalCommand implements IntelligentCommand {
50 51
     /** {@inheritDoc} */
51 52
     @Override
52 53
     public void execute(final InputWindow origin, final boolean isSilent,
53
-            final String... args) {
54
-        final String command = implodeArgs(args);
54
+            final CommandArguments args) {
55
+        final String command = args.getArgumentsAsString();
55 56
         
56 57
         final InputWindow window = (InputWindow) Main.getUI().getActiveWindow();
57 58
         

+ 9
- 8
src/com/dmdirc/commandparser/commands/global/AliasCommand.java Parādīt failu

@@ -26,6 +26,7 @@ import com.dmdirc.actions.Action;
26 26
 import com.dmdirc.actions.ActionManager;
27 27
 import com.dmdirc.actions.wrappers.Alias;
28 28
 import com.dmdirc.actions.wrappers.AliasWrapper;
29
+import com.dmdirc.commandparser.CommandArguments;
29 30
 import com.dmdirc.commandparser.CommandManager;
30 31
 import com.dmdirc.commandparser.commands.GlobalCommand;
31 32
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -55,15 +56,15 @@ public final class AliasCommand extends GlobalCommand implements
55 56
     /** {@inheritDoc} */
56 57
     @Override
57 58
     public void execute(final InputWindow origin, final boolean isSilent,
58
-                        final String... args) {
59
-        if (args.length < 2) {
59
+                        final CommandArguments args) {
60
+        if (args.getArguments().length < 2) {
60 61
             showUsage(origin, isSilent, "alias", "[--remove] <name> [command]");
61 62
             return;
62 63
         }
63 64
 
64
-        if (args[0].equalsIgnoreCase("--remove")) {
65
-            final String name = args[1].charAt(0) == CommandManager.getCommandChar()
66
-                ? args[1].substring(1) : args[1];
65
+        if (args.getArguments()[0].equalsIgnoreCase("--remove")) {
66
+            final String name = args.getArguments()[1].charAt(0) == CommandManager.getCommandChar()
67
+                ? args.getArguments()[1].substring(1) : args.getArguments()[1];
67 68
 
68 69
             if (doRemove(name)) {
69 70
                 sendLine(origin, isSilent, FORMAT_OUTPUT, "Alias '" + name +
@@ -76,8 +77,8 @@ public final class AliasCommand extends GlobalCommand implements
76 77
             return;
77 78
         }
78 79
 
79
-        final String name = args[0].charAt(0) == CommandManager.getCommandChar()
80
-                ? args[0].substring(0) : args[1];
80
+        final String name = args.getArguments()[0].charAt(0) == CommandManager.getCommandChar()
81
+                ? args.getArguments()[0].substring(0) : args.getArguments()[1];
81 82
 
82 83
         for (Action alias : AliasWrapper.getAliasWrapper()) {
83 84
             if (AliasWrapper.getCommandName(alias).substring(1).equalsIgnoreCase(
@@ -89,7 +90,7 @@ public final class AliasCommand extends GlobalCommand implements
89 90
         }
90 91
 
91 92
         final Alias myAlias = new Alias(name);
92
-        myAlias.setResponse(new String[]{implodeArgs(1, args)});
93
+        myAlias.setResponse(new String[]{args.getArgumentsAsString(1)});
93 94
         myAlias.createAction().save();
94 95
 
95 96
         sendLine(origin, isSilent, FORMAT_OUTPUT, "Alias '" + name +

+ 3
- 2
src/com/dmdirc/commandparser/commands/global/AllServers.java Parādīt failu

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerManager;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.GlobalCommand;
29 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -49,8 +50,8 @@ public final class AllServers extends GlobalCommand implements IntelligentComman
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
53
-        final String command = implodeArgs(args);
53
+            final CommandArguments args) {
54
+        final String command = args.getArgumentsAsString();
54 55
         InputWindow window;
55 56
         
56 57
         for (Server target : ServerManager.getServerManager().getServers()) {

+ 2
- 1
src/com/dmdirc/commandparser/commands/global/Clear.java Parādīt failu

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -49,7 +50,7 @@ public final class Clear extends GlobalCommand implements IntelligentCommand {
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final boolean isSilent, 
52
-            final String... args) {
53
+            final CommandArguments args) {
53 54
         origin.clear();
54 55
     }
55 56
     

+ 22
- 21
src/com/dmdirc/commandparser/commands/global/Debug.java Parādīt failu

@@ -24,6 +24,7 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27 28
 import com.dmdirc.commandparser.CommandManager;
28 29
 import com.dmdirc.commandparser.commands.GlobalCommand;
29 30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -64,42 +65,42 @@ public class Debug extends GlobalCommand implements IntelligentCommand {
64 65
     /** {@inheritDoc} */
65 66
     @Override
66 67
     public void execute(final InputWindow origin, final boolean isSilent,
67
-            final String ... args) {
68
-        if (args.length == 0) {
68
+            final CommandArguments args) {
69
+        if (args.getArguments().length == 0) {
69 70
             showUsage(origin, isSilent, "debug", "<debug command> [options]");
70
-        } else if ("error".equals(args[0])) {
71
-            doError(args);
72
-        } else if ("showraw".equals(args[0])) {
71
+        } else if ("error".equals(args.getArguments()[0])) {
72
+            doError(args.getArguments());
73
+        } else if ("showraw".equals(args.getArguments()[0])) {
73 74
             doShowRaw(origin, isSilent);
74
-        } else if ("configstats".equals(args[0])) {
75
+        } else if ("configstats".equals(args.getArguments()[0])) {
75 76
             doConfigStats(origin, isSilent);
76
-        } else if ("configinfo".equals(args[0])) {
77
+        } else if ("configinfo".equals(args.getArguments()[0])) {
77 78
             doConfigInfo(origin, isSilent);
78
-        } else if ("globalconfiginfo".equals(args[0])) {
79
+        } else if ("globalconfiginfo".equals(args.getArguments()[0])) {
79 80
             doGlobalConfigInfo(origin, isSilent);
80
-        } else if ("colourspam".equals(args[0])) {
81
+        } else if ("colourspam".equals(args.getArguments()[0])) {
81 82
             doColourSpam(origin, isSilent);
82
-        } else if ("meminfo".equals(args[0])) {
83
+        } else if ("meminfo".equals(args.getArguments()[0])) {
83 84
             doMemInfo(origin, isSilent);
84
-        } else if ("rungc".equals(args[0])) {
85
+        } else if ("rungc".equals(args.getArguments()[0])) {
85 86
             doGarbage(origin, isSilent);
86
-        } else if ("threads".equals(args[0])) {
87
+        } else if ("threads".equals(args.getArguments()[0])) {
87 88
             doThreads(origin, isSilent);
88
-        } else if ("forceupdate".equals(args[0])) {
89
+        } else if ("forceupdate".equals(args.getArguments()[0])) {
89 90
             doForceUpdate();
90
-        } else if ("serverinfo".equals(args[0])) {
91
+        } else if ("serverinfo".equals(args.getArguments()[0])) {
91 92
             doServerInfo(origin, isSilent);
92
-        } else if ("serverstate".equals(args[0])) {
93
+        } else if ("serverstate".equals(args.getArguments()[0])) {
93 94
             doServerState(origin, isSilent);
94
-        } else if ("benchmark".equals(args[0])) {
95
+        } else if ("benchmark".equals(args.getArguments()[0])) {
95 96
             doBenchmark(origin);
96
-        } else if ("services".equals(args[0])) {
97
-            doServices(origin, isSilent, args);
98
-        } else if ("firstrun".equals(args[0])) {
97
+        } else if ("services".equals(args.getArguments()[0])) {
98
+            doServices(origin, isSilent, args.getArguments());
99
+        } else if ("firstrun".equals(args.getArguments()[0])) {
99 100
             Main.getUI().showFirstRunWizard();
100
-        } else if ("migration".equals(args[0])) {
101
+        } else if ("migration".equals(args.getArguments()[0])) {
101 102
             Main.getUI().showMigrationWizard();
102
-        } else if ("notify".equals(args[0])) {
103
+        } else if ("notify".equals(args.getArguments()[0])) {
103 104
             sendLine(origin, isSilent, FORMAT_OUTPUT, "Current notification colour is: "
104 105
                     + origin.getContainer().getNotification());
105 106
         } else {

+ 11
- 9
src/com/dmdirc/commandparser/commands/global/Echo.java Parādīt failu

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Main;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -52,35 +53,36 @@ public final class Echo extends GlobalCommand implements IntelligentCommand {
52 53
     /** {@inheritDoc} */
53 54
     @Override
54 55
     public void execute(final InputWindow origin, final boolean isSilent,
55
-            final String... args) {
56
-        if (args.length > 0 && args[0].equalsIgnoreCase("--active")) {
56
+            final CommandArguments args) {
57
+        if (args.getArguments().length > 0
58
+                && args.getArguments()[0].equalsIgnoreCase("--active")) {
57 59
             final Window frame = Main.getUI().getActiveWindow();
58 60
             if (frame instanceof InputWindow) {
59
-                ((InputWindow) frame).addLine(FORMAT_OUTPUT, implodeArgs(1,
60
-                        args));
61
+                ((InputWindow) frame).addLine(FORMAT_OUTPUT, args.getArgumentsAsString(1));
61 62
             }
62
-        } else if (args.length > 1 && args[0].equalsIgnoreCase("--target")) {
63
+        } else if (args.getArguments().length > 1
64
+                && args.getArguments()[0].equalsIgnoreCase("--target")) {
63 65
             Window frame = null;
64 66
             Window target = origin;
65 67
 
66 68
             while (frame == null && target != null) {
67
-                frame = WindowManager.findCustomWindow(target, args[1]);
69
+                frame = WindowManager.findCustomWindow(target, args.getArguments()[1]);
68 70
                 target = WindowManager.getParent(target);
69 71
             }
70 72
 
71 73
             if (frame == null) {
72
-                frame = WindowManager.findCustomWindow(args[1]);
74
+                frame = WindowManager.findCustomWindow(args.getArguments()[1]);
73 75
             }
74 76
 
75 77
             if (frame == null) {
76 78
                 sendLine(origin, isSilent, FORMAT_ERROR,
77 79
                         "Unable to find target window");
78 80
             } else {
79
-                frame.addLine(FORMAT_OUTPUT, implodeArgs(2, args));
81
+                frame.addLine(FORMAT_OUTPUT, args.getArgumentsAsString(2));
80 82
             }
81 83
 
82 84
         } else {
83
-            sendLine(origin, isSilent, FORMAT_OUTPUT, implodeArgs(args));
85
+            sendLine(origin, isSilent, FORMAT_OUTPUT, args.getArgumentsAsString());
84 86
         }
85 87
     }
86 88
 

+ 3
- 2
src/com/dmdirc/commandparser/commands/global/Exit.java Parādīt failu

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Main;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.ui.interfaces.InputWindow;
@@ -47,8 +48,8 @@ public final class Exit extends GlobalCommand {
47 48
     /** {@inheritDoc} */
48 49
     @Override
49 50
     public void execute(final InputWindow origin, final boolean isSilent,
50
-            final String... args) {                
51
-        Main.quit(args.length > 0 ? implodeArgs(args)
51
+            final CommandArguments args) {
52
+        Main.quit(args.getArguments().length > 0 ? args.getArgumentsAsString()
52 53
                 : origin.getConfigManager().getOption("general", "closemessage"));
53 54
     }
54 55
     

+ 4
- 3
src/com/dmdirc/commandparser/commands/global/Help.java Parādīt failu

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandInfo;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.CommandType;
@@ -58,11 +59,11 @@ public final class Help extends GlobalCommand implements IntelligentCommand {
58 59
     /** {@inheritDoc} */
59 60
     @Override
60 61
     public void execute(final InputWindow origin, final boolean isSilent,
61
-            final String... args) {
62
-        if (args.length == 0) {
62
+            final CommandArguments args) {
63
+        if (args.getArguments().length == 0) {
63 64
             showAllCommands(origin, isSilent);
64 65
         } else {
65
-            showCommand(origin, isSilent, args[0]);
66
+            showCommand(origin, isSilent, args.getArguments()[0]);
66 67
         }
67 68
     }
68 69
     

+ 7
- 6
src/com/dmdirc/commandparser/commands/global/Ifplugin.java Parādīt failu

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
@@ -54,15 +55,15 @@ public final class Ifplugin extends GlobalCommand implements IntelligentCommand
54 55
     /** {@inheritDoc} */
55 56
     @Override
56 57
     public void execute(final InputWindow origin, final boolean isSilent,
57
-            final String... args) {
58
-        if (args.length <= 1) {
58
+            final CommandArguments args) {
59
+        if (args.getArguments().length <= 1) {
59 60
             showUsage(origin, isSilent, "ifplugin", "<[!]plugin> <command>");
60 61
             return;
61 62
         }
62 63
         
63
-        final boolean negative = args[0].charAt(0) == '!';
64
+        final boolean negative = args.getArguments()[0].charAt(0) == '!';
64 65
         
65
-        final String pname = args[0].substring(negative ? 1 : 0);
66
+        final String pname = args.getArguments()[0].substring(negative ? 1 : 0);
66 67
         
67 68
         final PluginInfo pluginInfo = PluginManager.getPluginManager().getPluginInfoByName(pname);
68 69
         
@@ -75,9 +76,9 @@ public final class Ifplugin extends GlobalCommand implements IntelligentCommand
75 76
         if (result != negative) {
76 77
             if (origin == null) {
77 78
                 GlobalCommandParser.getGlobalCommandParser().parseCommand(null,
78
-                        implodeArgs(1, args));
79
+                        args.getArgumentsAsString(1));
79 80
             } else {
80
-                origin.getCommandParser().parseCommand(origin, implodeArgs(1, args));
81
+                origin.getCommandParser().parseCommand(origin, args.getArgumentsAsString(1));
81 82
             }
82 83
         }
83 84
     }

+ 6
- 4
src/com/dmdirc/commandparser/commands/global/LoadPlugin.java Parādīt failu

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -50,15 +51,16 @@ public final class LoadPlugin extends GlobalCommand implements IntelligentComman
50 51
     /** {@inheritDoc} */
51 52
     @Override
52 53
     public void execute(final InputWindow origin, final boolean isSilent,
53
-            final String... args) {
54
-        if (args.length == 0) {
54
+            final CommandArguments args) {
55
+        if (args.getArguments().length == 0) {
55 56
             showUsage(origin, isSilent, "loadplugin", "<plugin>");
56 57
             return;
57 58
         }
58 59
 
59 60
         // Add previously unknown plugin to plugin manager
60
-        PluginManager.getPluginManager().addPlugin(args[0]);
61
-        final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfo(args[0]);
61
+        PluginManager.getPluginManager().addPlugin(args.getArguments()[0]);
62
+        final PluginInfo plugin = PluginManager.getPluginManager()
63
+                .getPluginInfo(args.getArguments()[0]);
62 64
         
63 65
         if (plugin == null) {
64 66
             sendLine(origin, isSilent, FORMAT_ERROR, "Plugin loading failed");

+ 9
- 8
src/com/dmdirc/commandparser/commands/global/NewServer.java Parādīt failu

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.config.IdentityManager;
@@ -49,8 +50,8 @@ public final class NewServer extends GlobalCommand {
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
53
-        if (args.length == 0) {
53
+            final CommandArguments args) {
54
+        if (args.getArguments().length == 0) {
54 55
             showUsage(origin, isSilent, "newserver", "<host[:[+]port]> [password]");
55 56
             return;
56 57
         }
@@ -62,7 +63,7 @@ public final class NewServer extends GlobalCommand {
62 63
         int offset = 0;
63 64
         
64 65
         // Check for SSL
65
-        if (args[offset].equalsIgnoreCase("--ssl")) {
66
+        if (args.getArguments()[offset].equalsIgnoreCase("--ssl")) {
66 67
             Logger.userError(ErrorLevel.LOW, 
67 68
                     "Using /newserver --ssl is deprecated, and may be removed in the future."
68 69
                     + " Use /newserver <host>:+<port> instead.");
@@ -72,8 +73,8 @@ public final class NewServer extends GlobalCommand {
72 73
         }
73 74
         
74 75
         // Check for port
75
-        if (args[offset].indexOf(':') > -1) {
76
-            final String[] parts = args[offset].split(":");
76
+        if (args.getArguments()[offset].indexOf(':') > -1) {
77
+            final String[] parts = args.getArguments()[offset].split(":");
77 78
             host = parts[0];
78 79
             
79 80
             if (parts[1].length() > 0 && parts[1].charAt(0) == '+') {
@@ -93,12 +94,12 @@ public final class NewServer extends GlobalCommand {
93 94
                 return;
94 95
             }            
95 96
         } else {
96
-            host = args[offset];
97
+            host = args.getArguments()[offset];
97 98
         }
98 99
         
99 100
         // Check for password
100
-        if (args.length > ++offset) {
101
-            pass = implodeArgs(offset, args);
101
+        if (args.getArguments().length > ++offset) {
102
+            pass = args.getArgumentsAsString(offset);
102 103
         }
103 104
         
104 105
         new Server(host, port, pass, ssl, IdentityManager.getProfiles().get(0));

+ 4
- 3
src/com/dmdirc/commandparser/commands/global/Notify.java Parādīt failu

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -52,13 +53,13 @@ public final class Notify extends GlobalCommand implements IntelligentCommand {
52 53
     /** {@inheritDoc} */
53 54
     @Override
54 55
     public void execute(final InputWindow origin, final boolean isSilent,
55
-            final String... args) {
56
-        if (args.length == 0) {
56
+            final CommandArguments args) {
57
+        if (args.getArguments().length == 0) {
57 58
             showUsage(origin, isSilent, "notify", "<colour>");
58 59
             return;
59 60
         }
60 61
         
61
-        final Color colour = ColourManager.parseColour(args[0], null);
62
+        final Color colour = ColourManager.parseColour(args.getArguments()[0], null);
62 63
         
63 64
         if (colour == null) {
64 65
             showUsage(origin, isSilent, "notify",

+ 11
- 10
src/com/dmdirc/commandparser/commands/global/OpenWindow.java Parādīt failu

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.CustomWindow;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -49,11 +50,11 @@ public class OpenWindow extends GlobalCommand implements IntelligentCommand {
49 50
     /** {@inheritDoc} */
50 51
     @Override
51 52
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
53
+            final CommandArguments args) {
53 54
         int start = 0;
54 55
         Window parent = null;
55 56
 
56
-        if (args.length > 0 && "--server".equals(args[0])) {
57
+        if (args.getArguments().length > 0 && "--server".equals(args.getArguments()[0])) {
57 58
             if (origin.getContainer().getServer() == null) {
58 59
                 sendLine(origin, isSilent, FORMAT_ERROR,
59 60
                         "This window doesn't have an associated server.");
@@ -62,31 +63,31 @@ public class OpenWindow extends GlobalCommand implements IntelligentCommand {
62 63
 
63 64
             parent = origin.getContainer().getServer().getFrame();
64 65
             start = 1;
65
-        } else if (args.length > 0 && "--child".equals(args[0])) {
66
+        } else if (args.getArguments().length > 0 && "--child".equals(args.getArguments()[0])) {
66 67
             parent = origin;
67 68
             start = 1;
68 69
         }
69 70
 
70
-        if (args.length == start || args[start].isEmpty()) {
71
+        if (args.getArguments().length == start || args.getArguments()[start].isEmpty()) {
71 72
             showUsage(origin, isSilent, "openwindow",
72 73
                     "[--server|--child] <name> [title]");
73 74
         } else {
74 75
             Window window;
75 76
             
76 77
             if (parent == null) {
77
-                window = WindowManager.findCustomWindow(args[start]);
78
+                window = WindowManager.findCustomWindow(args.getArguments()[start]);
78 79
             } else {
79
-                window = WindowManager.findCustomWindow(parent, args[start]);
80
+                window = WindowManager.findCustomWindow(parent, args.getArguments()[start]);
80 81
             }
81 82
             
82
-            final String title = args.length > start + 1 ? implodeArgs(
83
-                    start + 1, args) : args[start];
83
+            final String title = args.getArguments().length > start + 1 ?
84
+                args.getArgumentsAsString(start + 1): args.getArguments()[start];
84 85
 
85 86
             if (window == null) {
86 87
                 if (parent == null) {
87
-                    new CustomWindow(args[start], title);
88
+                    new CustomWindow(args.getArguments()[start], title);
88 89
                 } else {
89
-                    new CustomWindow(args[start], title, parent);
90
+                    new CustomWindow(args.getArguments()[start], title, parent);
90 91
                 }
91 92
             } else {
92 93
                 sendLine(origin, isSilent, FORMAT_ERROR,

+ 2
- 1
src/com/dmdirc/commandparser/commands/global/ReloadActions.java Parādīt failu

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26
+import com.dmdirc.commandparser.CommandArguments;
26 27
 import com.dmdirc.commandparser.CommandManager;
27 28
 import com.dmdirc.commandparser.commands.GlobalCommand;
28 29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -48,7 +49,7 @@ public final class ReloadActions extends GlobalCommand implements IntelligentCom
48 49
     
49 50
     /** {@inheritDoc} */
50 51
     public void execute(final InputWindow origin, final boolean isSilent,
51
-            final String... args) {
52
+            final CommandArguments args) {
52 53
         ActionManager.loadActions();
53 54
         sendLine(origin, isSilent, FORMAT_OUTPUT, "Actions reloaded.");
54 55
     }

+ 4
- 3
src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java Parādīt failu

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -51,13 +52,13 @@ public final class ReloadPlugin extends GlobalCommand implements IntelligentComm
51 52
     /** {@inheritDoc} */
52 53
     @Override
53 54
     public void execute(final InputWindow origin, final boolean isSilent,
54
-            final String... args) {
55
-        if (args.length == 0) {
55
+            final CommandArguments args) {
56
+        if (args.getArguments().length == 0) {
56 57
             showUsage(origin, isSilent, "reloadplugin", "<plugin>");
57 58
             return;
58 59
         }
59 60
         
60
-        final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfoByName(args[0]);
61
+        final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfoByName(args.getArguments()[0]);
61 62
         if (plugin == null) {
62 63
             sendLine(origin, isSilent, FORMAT_ERROR, "Plugin Reloading failed - Plugin not loaded");
63 64
         } else if (PluginManager.getPluginManager().reloadPlugin(plugin.getRelativeFilename())) {

+ 9
- 4
src/com/dmdirc/commandparser/commands/global/SaveConfig.java Parādīt failu

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -48,25 +49,29 @@ public final class SaveConfig extends GlobalCommand implements IntelligentComman
48 49
     }
49 50
     
50 51
     /** {@inheritDoc} */
52
+    @Override
51 53
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
54
+            final CommandArguments args) {
53 55
         IdentityManager.save();
54 56
         
55 57
         sendLine(origin, isSilent, FORMAT_OUTPUT, "Configuration file saved.");
56 58
     }
57 59
     
58 60
     
59
-    /** {@inheritDoc}. */
61
+    /** {@inheritDoc} */
62
+    @Override
60 63
     public String getName() {
61 64
         return "saveconfig";
62 65
     }
63 66
     
64
-    /** {@inheritDoc}. */
67
+    /** {@inheritDoc} */
68
+    @Override
65 69
     public boolean showInHelp() {
66 70
         return true;
67 71
     }
68 72
     
69
-    /** {@inheritDoc}. */
73
+    /** {@inheritDoc} */
74
+    @Override
70 75
     public String getHelp() {
71 76
         return "saveconfig - force the client to save its configuration to disk";
72 77
     }

+ 18
- 12
src/com/dmdirc/commandparser/commands/global/Set.java Parādīt failu

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -52,38 +53,43 @@ public final class Set extends GlobalCommand implements IntelligentCommand {
52 53
     /** {@inheritDoc} */
53 54
     @Override
54 55
     public void execute(final InputWindow origin, final boolean isSilent,
55
-            final String... args) {
56
+            final CommandArguments args) {
56 57
         int i = 0;
57 58
         
58 59
         Identity identity = IdentityManager.getConfigIdentity();
59 60
         ConfigManager manager = IdentityManager.getGlobalConfig();
60 61
         
61
-        if (args.length > 0 && "--server".equalsIgnoreCase(args[0]) && origin != null
62
+        if (args.getArguments().length > 0
63
+                && "--server".equalsIgnoreCase(args.getArguments()[0]) && origin != null
62 64
                 && origin.getContainer().getServer() != null) {
63 65
             i = 1;
64 66
             identity = origin.getContainer().getServer().getServerIdentity();
65 67
             manager = origin.getContainer().getServer().getConfigManager();
66 68
         }
67 69
         
68
-        switch (args.length - i) {
70
+        switch (args.getArguments().length - i) {
69 71
         case 0:
70 72
             doDomainList(origin, isSilent, manager);
71 73
             break;
72 74
         case 1:
73
-            doOptionsList(origin, isSilent, manager, args[i]);
75
+            doOptionsList(origin, isSilent, manager, args.getArguments()[i]);
74 76
             break;
75 77
         case 2:
76
-            doShowOption(origin, isSilent, manager, args[i], args[1 + i]);
78
+            doShowOption(origin, isSilent, manager, args.getArguments()[i],
79
+                    args.getArguments()[1 + i]);
77 80
             break;
78 81
         default:
79
-            if (args[i].equalsIgnoreCase("--unset")) {
80
-                doUnsetOption(origin, isSilent, identity, args[1 + i], args[2 + i]);
81
-            } else if (args[i].equalsIgnoreCase("--append") && args.length > 3 + i) {
82
-                doAppendOption(origin, isSilent, identity, manager, args[1 + i], args[2 + i],
83
-                        implodeArgs(3 + i, args));
82
+            if (args.getArguments()[i].equalsIgnoreCase("--unset")) {
83
+                doUnsetOption(origin, isSilent, identity, args.getArguments()[1 + i],
84
+                        args.getArguments()[2 + i]);
85
+            } else if (args.getArguments()[i].equalsIgnoreCase("--append")
86
+                    && args.getArguments().length > 3 + i) {
87
+                doAppendOption(origin, isSilent, identity, manager, 
88
+                        args.getArguments()[1 + i], args.getArguments()[2 + i],
89
+                        args.getArgumentsAsString(3 + i));
84 90
             } else {
85
-                doSetOption(origin, isSilent, identity, args[i], args[1 + i],
86
-                        implodeArgs(2 + i, args));
91
+                doSetOption(origin, isSilent, identity, args.getArguments()[i],
92
+                        args.getArguments()[1 + i], args.getArgumentsAsString(2 + i));
87 93
             }
88 94
         }
89 95
     }

+ 5
- 3
src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java Parādīt failu

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandparser.commands.global;
24 24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27 28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
@@ -51,13 +52,14 @@ public final class UnloadPlugin extends GlobalCommand implements IntelligentComm
51 52
     /** {@inheritDoc} */
52 53
     @Override
53 54
     public void execute(final InputWindow origin, final boolean isSilent,
54
-            final String... args) {
55
-        if (args.length == 0) {
55
+            final CommandArguments args) {
56
+        if (args.getArguments().length == 0) {
56 57
             showUsage(origin, isSilent, "unloadplugin", "<plugin>");
57 58
             return;
58 59
         }
59 60
         
60
-        final PluginInfo plugin = PluginManager.getPluginManager().getPluginInfoByName(args[0]);
61
+        final PluginInfo plugin = PluginManager.getPluginManager()
62
+                .getPluginInfoByName(args.getArguments()[0]);
61 63
         if (plugin == null) {
62 64
             sendLine(origin, isSilent, FORMAT_ERROR, "Plugin unloading failed - Plugin not loaded");
63 65
         } else if (PluginManager.getPluginManager().delPlugin(plugin.getRelativeFilename())) {

Notiek ielāde…
Atcelt
Saglabāt