Browse Source

Update all plugin commands to use the new arguments

tags/0.6.3m1rc1
Chris Smith 15 years ago
parent
commit
a48c5c00ee

+ 5
- 9
src/com/dmdirc/addons/audio/AudioCommand.java View File

22
 
22
 
23
 package com.dmdirc.addons.audio;
23
 package com.dmdirc.addons.audio;
24
 
24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.ui.interfaces.InputWindow;
28
 import com.dmdirc.ui.interfaces.InputWindow;
43
 		CommandManager.registerCommand(this);
44
 		CommandManager.registerCommand(this);
44
 	}
45
 	}
45
 		
46
 		
46
-	/**
47
-	 * Executes this command.
48
-	 *
49
-	 * @param origin The frame in which this command was issued
50
-	 * @param isSilent Whether this command is silenced or not
51
-	 * @param args The user supplied arguments
52
-	 */
47
+	/** {@inheritDoc} */
53
     @Override
48
     @Override
54
-	public void execute(final InputWindow origin, final boolean isSilent, final String... args) {
55
-		final String filename = implodeArgs(args);
49
+	public void execute(final InputWindow origin, final boolean isSilent,
50
+            final CommandArguments args) {
51
+		final String filename = args.getArgumentsAsString();
56
 		final File file = new File(filename);
52
 		final File file = new File(filename);
57
 		if (file.exists()) {
53
 		if (file.exists()) {
58
 			if (AudioPlayer.isValid(file)) {
54
 			if (AudioPlayer.isValid(file)) {

+ 4
- 8
src/com/dmdirc/addons/audio/BeepCommand.java View File

22
 
22
 
23
 package com.dmdirc.addons.audio;
23
 package com.dmdirc.addons.audio;
24
 
24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.ui.interfaces.InputWindow;
28
 import com.dmdirc.ui.interfaces.InputWindow;
43
 		CommandManager.registerCommand(this);
44
 		CommandManager.registerCommand(this);
44
 	}
45
 	}
45
 		
46
 		
46
-	/**
47
-	 * Executes this command.
48
-	 *
49
-	 * @param origin The frame in which this command was issued
50
-	 * @param isSilent Whether this command is silenced or not
51
-	 * @param args The user supplied arguments
52
-	 */
47
+	/** {@inheritDoc} */
53
     @Override
48
     @Override
54
-	public void execute(final InputWindow origin, final boolean isSilent, final String... args) {
49
+	public void execute(final InputWindow origin, final boolean isSilent,
50
+            final CommandArguments args) {
55
 		Toolkit.getDefaultToolkit().beep();
51
 		Toolkit.getDefaultToolkit().beep();
56
 	}
52
 	}
57
 
53
 

+ 12
- 16
src/com/dmdirc/addons/dcc/DCCCommand.java View File

37
 import com.dmdirc.addons.dcc.kde.KFileChooser;
37
 import com.dmdirc.addons.dcc.kde.KFileChooser;
38
 import com.dmdirc.addons.dcc.actions.DCCActions;
38
 import com.dmdirc.addons.dcc.actions.DCCActions;
39
 
39
 
40
+import com.dmdirc.commandparser.CommandArguments;
40
 import javax.swing.JFileChooser;
41
 import javax.swing.JFileChooser;
41
 import javax.swing.JFrame;
42
 import javax.swing.JFrame;
42
 import javax.swing.JOptionPane;
43
 import javax.swing.JOptionPane;
66
 		CommandManager.registerCommand(this);
67
 		CommandManager.registerCommand(this);
67
 	}
68
 	}
68
 		
69
 		
69
-	/**
70
-	 * Executes this command.
71
-	 *
72
-	 * @param origin The frame in which this command was issued
73
-	 * @param server The server instance that this command is being executed on
74
-	 * @param isSilent Whether this command is silenced or not
75
-	 * @param args The user supplied arguments
76
-	 */
70
+	/** {@inheritDoc} */
77
 	@Override
71
 	@Override
78
-	public void execute(final InputWindow origin, final Server server, final boolean isSilent, final String... args) {
79
-		if (args.length > 1) {
80
-			final String type = args[0];
81
-			final String target = args[1];
72
+	public void execute(final InputWindow origin, final Server server,
73
+            final boolean isSilent, final CommandArguments args) {
74
+		if (args.getArguments().length > 1) {
75
+			final String type = args.getArguments()[0];
76
+			final String target = args.getArguments()[1];
82
 			final IRCParser parser = server.getParser();
77
 			final IRCParser parser = server.getParser();
83
 			final String myNickname = parser.getMyNickname();
78
 			final String myNickname = parser.getMyNickname();
84
 				
79
 				
112
 					sendLine(origin, isSilent, "DCCChatError", "Unable to start chat with "+target+" - unable to create listen socket");
107
 					sendLine(origin, isSilent, "DCCChatError", "Unable to start chat with "+target+" - unable to create listen socket");
113
 				}
108
 				}
114
 			} else if (type.equalsIgnoreCase("send")) {
109
 			} else if (type.equalsIgnoreCase("send")) {
115
-				sendFile(target, origin, server, isSilent, args);
110
+				sendFile(target, origin, server, isSilent, args.getArgumentsAsString(2));
116
 			} else {
111
 			} else {
117
 				sendLine(origin, isSilent, FORMAT_ERROR, "Unknown DCC Type: '"+type+"'");
112
 				sendLine(origin, isSilent, FORMAT_ERROR, "Unknown DCC Type: '"+type+"'");
118
 			}
113
 			}
128
 	 * @param origin The InputWindow this command was issued on
123
 	 * @param origin The InputWindow this command was issued on
129
 	 * @param server The server instance that this command is being executed on
124
 	 * @param server The server instance that this command is being executed on
130
 	 * @param isSilent Whether this command is silenced or not
125
 	 * @param isSilent Whether this command is silenced or not
131
-	 * @param args Arguments passed.
126
+	 * @param filename The file to send
127
+     * @since 0.6.3
132
 	 */
128
 	 */
133
-	public void sendFile(final String target, final InputWindow origin, final Server server, final boolean isSilent, final String... args) {
129
+	public void sendFile(final String target, final InputWindow origin, final Server server, final boolean isSilent, final String filename) {
134
 		// New thread to ask the user what file to send
130
 		// New thread to ask the user what file to send
135
-		final File givenFile = new File(implodeArgs(2, args));
131
+		final File givenFile = new File(filename);
136
 		final Thread dccThread = new Thread(new Runnable() {
132
 		final Thread dccThread = new Thread(new Runnable() {
137
 			/** {@inheritDoc} */
133
 			/** {@inheritDoc} */
138
 			@Override
134
 			@Override

+ 6
- 11
src/com/dmdirc/addons/dcop/DcopCommand.java View File

23
 package com.dmdirc.addons.dcop;
23
 package com.dmdirc.addons.dcop;
24
 
24
 
25
 import com.dmdirc.Server;
25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26
 import com.dmdirc.commandparser.CommandManager;
27
 import com.dmdirc.commandparser.CommandManager;
27
 import com.dmdirc.commandparser.commands.ServerCommand;
28
 import com.dmdirc.commandparser.commands.ServerCommand;
28
 import com.dmdirc.ui.interfaces.InputWindow;
29
 import com.dmdirc.ui.interfaces.InputWindow;
43
         
44
         
44
         CommandManager.registerCommand(this);
45
         CommandManager.registerCommand(this);
45
     }
46
     }
46
-    
47
-    /**
48
-     * Executes this command.
49
-     * @param origin The frame in which this command was issued
50
-     * @param server The server object that this command is associated with
51
-     * @param isSilent Whether this command is silenced or not
52
-     * @param args The user supplied arguments
53
-     */
47
+
48
+    /** {@inheritDoc} */
54
     @Override
49
     @Override
55
     public void execute(final InputWindow origin, final Server server,
50
     public void execute(final InputWindow origin, final Server server,
56
-            final boolean isSilent, final String... args) {
57
-        if (args.length != 3) {
51
+            final boolean isSilent, final CommandArguments args) {
52
+        if (args.getArguments().length != 3) {
58
             showUsage(origin, isSilent, "dcop", "<app> <object> <function>");
53
             showUsage(origin, isSilent, "dcop", "<app> <object> <function>");
59
             return;
54
             return;
60
         }
55
         }
61
         
56
         
62
-        final List<String> res = DcopPlugin.getDcopResult("dcop " + implodeArgs(args));
57
+        final List<String> res = DcopPlugin.getDcopResult("dcop " + args.getArgumentsAsString());
63
         for (String line : res) {
58
         for (String line : res) {
64
             sendLine(origin, isSilent, FORMAT_OUTPUT, line);
59
             sendLine(origin, isSilent, FORMAT_OUTPUT, line);
65
         }
60
         }

+ 11
- 6
src/com/dmdirc/addons/dns/DNSCommand.java View File

22
 
22
 
23
 package com.dmdirc.addons.dns;
23
 package com.dmdirc.addons.dns;
24
 
24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.ui.interfaces.InputWindow;
28
 import com.dmdirc.ui.interfaces.InputWindow;
44
     /** {@inheritDoc} */
45
     /** {@inheritDoc} */
45
     @Override
46
     @Override
46
     public void execute(final InputWindow origin, final boolean isSilent,
47
     public void execute(final InputWindow origin, final boolean isSilent,
47
-            final String... args) {
48
-        if (args.length == 0) {
48
+            final CommandArguments args) {
49
+        if (args.getArguments().length == 0) {
49
             showUsage(origin, isSilent, "dns", "<IP|hostname>");
50
             showUsage(origin, isSilent, "dns", "<IP|hostname>");
50
             return;
51
             return;
51
         }
52
         }
52
         
53
         
53
-        sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolving: " + args[0]);
54
+        sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolving: " + args.getArguments()[0]);
54
         new Timer("DNS Command Timer").schedule(new TimerTask() {
55
         new Timer("DNS Command Timer").schedule(new TimerTask() {
55
             /** {@inheritDoc} */
56
             /** {@inheritDoc} */
56
             @Override
57
             @Override
57
             public void run() {
58
             public void run() {
58
-                if (args[0].matches("\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b")) {
59
-                    sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: " + args[0] + ": " + DNSPlugin.getHostname(args[0]));
59
+                if (args.getArguments()[0].matches("\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b")) {
60
+                    sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: "
61
+                            + args.getArguments()[0] + ": "
62
+                            + DNSPlugin.getHostname(args.getArguments()[0]));
60
                 } else {
63
                 } else {
61
-                    sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: " + args[0] + ": " + DNSPlugin.getIPs(args[0]));
64
+                    sendLine(origin, isSilent, FORMAT_OUTPUT, "Resolved: "
65
+                            + args.getArguments()[0] + ": "
66
+                            + DNSPlugin.getIPs(args.getArguments()[0]));
62
                 }
67
                 }
63
             }
68
             }
64
         }, 0);
69
         }, 0);

+ 9
- 14
src/com/dmdirc/addons/logging/LoggingCommand.java View File

23
 package com.dmdirc.addons.logging;
23
 package com.dmdirc.addons.logging;
24
 
24
 
25
 import com.dmdirc.Server;
25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26
 import com.dmdirc.commandparser.CommandManager;
27
 import com.dmdirc.commandparser.CommandManager;
27
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28
 import com.dmdirc.commandparser.commands.ServerCommand;
29
 import com.dmdirc.commandparser.commands.ServerCommand;
48
 		CommandManager.registerCommand(this);
49
 		CommandManager.registerCommand(this);
49
 	}
50
 	}
50
 		
51
 		
51
-	/**
52
-	 * Executes this command.
53
-	 *
54
-	 * @param origin The frame in which this command was issued
55
-	 * @param server The server object that this command is associated with
56
-	 * @param isSilent Whether this command is silenced or not
57
-	 * @param args The user supplied arguments
58
-	 */
52
+    /** {@inheritDoc} */
59
     @Override
53
     @Override
60
-	public void execute(final InputWindow origin, final Server server, final boolean isSilent, final String... args) {
54
+	public void execute(final InputWindow origin, final Server server,
55
+            final boolean isSilent, final CommandArguments args) {
61
 		final PluginInfo pluginInfo = PluginManager.getPluginManager().getPluginInfoByName("logging");
56
 		final PluginInfo pluginInfo = PluginManager.getPluginManager().getPluginInfoByName("logging");
62
 		if (pluginInfo == null) { 
57
 		if (pluginInfo == null) { 
63
 			sendLine(origin, isSilent, FORMAT_ERROR, "Logging Plugin is not loaded.");
58
 			sendLine(origin, isSilent, FORMAT_ERROR, "Logging Plugin is not loaded.");
72
 		
67
 		
73
 		final LoggingPlugin plugin = (LoggingPlugin) gotPlugin;
68
 		final LoggingPlugin plugin = (LoggingPlugin) gotPlugin;
74
 		
69
 		
75
-		if (args.length > 0) {
76
-			if (args[0].equalsIgnoreCase("reload")) {
70
+		if (args.getArguments().length > 0) {
71
+			if (args.getArguments()[0].equalsIgnoreCase("reload")) {
77
 				if (PluginManager.getPluginManager().reloadPlugin(pluginInfo.getFilename())) {
72
 				if (PluginManager.getPluginManager().reloadPlugin(pluginInfo.getFilename())) {
78
 					sendLine(origin, isSilent, FORMAT_OUTPUT, "Plugin reloaded.");
73
 					sendLine(origin, isSilent, FORMAT_OUTPUT, "Plugin reloaded.");
79
 				} else {
74
 				} else {
80
 					sendLine(origin, isSilent, FORMAT_ERROR, "Plugin failed to reload.");
75
 					sendLine(origin, isSilent, FORMAT_ERROR, "Plugin failed to reload.");
81
 				}
76
 				}
82
-			} else if (args[0].equalsIgnoreCase("history")) {
77
+			} else if (args.getArguments()[0].equalsIgnoreCase("history")) {
83
 				if (!plugin.showHistory(origin)) {
78
 				if (!plugin.showHistory(origin)) {
84
 					sendLine(origin, isSilent, FORMAT_ERROR, "Unable to open history for this window.");
79
 					sendLine(origin, isSilent, FORMAT_ERROR, "Unable to open history for this window.");
85
     		}
80
     		}
86
-			} else if (args[0].equalsIgnoreCase("help")) {
81
+			} else if (args.getArguments()[0].equalsIgnoreCase("help")) {
87
 				sendLine(origin, isSilent, FORMAT_OUTPUT, getName() + " reload           - Reload the logging plugin.");
82
 				sendLine(origin, isSilent, FORMAT_OUTPUT, getName() + " reload           - Reload the logging plugin.");
88
 				sendLine(origin, isSilent, FORMAT_OUTPUT, getName() + " history          - Open the history of this window, if available.");
83
 				sendLine(origin, isSilent, FORMAT_OUTPUT, getName() + " history          - Open the history of this window, if available.");
89
 				sendLine(origin, isSilent, FORMAT_OUTPUT, getName() + " help             - Show this help.");
84
 				sendLine(origin, isSilent, FORMAT_OUTPUT, getName() + " help             - Show this help.");
90
 			} else {
85
 			} else {
91
-				sendLine(origin, isSilent, FORMAT_ERROR, "Unknown command '" + args[0] + "'. Use " + getName() + " help for a list of commands.");
86
+				sendLine(origin, isSilent, FORMAT_ERROR, "Unknown command '" + args.getArguments()[0] + "'. Use " + getName() + " help for a list of commands.");
92
 			}
87
 			}
93
 		} else {
88
 		} else {
94
 			sendLine(origin, isSilent, FORMAT_ERROR, "Use " + getName() + " help for a list of commands.");
89
 			sendLine(origin, isSilent, FORMAT_ERROR, "Use " + getName() + " help for a list of commands.");

+ 8
- 5
src/com/dmdirc/addons/nowplaying/NowPlayingCommand.java View File

24
 
24
 
25
 import com.dmdirc.MessageTarget;
25
 import com.dmdirc.MessageTarget;
26
 import com.dmdirc.Server;
26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27
 import com.dmdirc.commandparser.commands.ChatCommand;
28
 import com.dmdirc.commandparser.commands.ChatCommand;
28
 import com.dmdirc.commandparser.CommandManager;
29
 import com.dmdirc.commandparser.CommandManager;
29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
30
 import com.dmdirc.commandparser.commands.IntelligentCommand;
59
     /** {@inheritDoc} */
60
     /** {@inheritDoc} */
60
     @Override
61
     @Override
61
     public void execute(final InputWindow origin, final Server server,
62
     public void execute(final InputWindow origin, final Server server,
62
-            final MessageTarget target, final boolean isSilent, final String ... args) {
63
-        if (args.length > 0 && args[0].equalsIgnoreCase("--sources")) {
63
+            final MessageTarget target, final boolean isSilent, final CommandArguments args) {
64
+        if (args.getArguments().length > 0 && args.getArguments()[0]
65
+                .equalsIgnoreCase("--sources")) {
64
             doSourceList(origin, isSilent);
66
             doSourceList(origin, isSilent);
65
-        } else if (args.length > 0 && args[0].equalsIgnoreCase("--source")) {
66
-            if (args.length > 1) {
67
-                final String sourceName = args[1];
67
+        } else if (args.getArguments().length > 0 && args.getArguments()[0]
68
+                .equalsIgnoreCase("--source")) {
69
+            if (args.getArguments().length > 1) {
70
+                final String sourceName = args.getArguments()[1];
68
                 final MediaSource source = parent.getSource(sourceName);
71
                 final MediaSource source = parent.getSource(sourceName);
69
                 
72
                 
70
                 if (source == null) {
73
                 if (source == null) {

+ 5
- 3
src/com/dmdirc/addons/osd/OsdCommand.java View File

22
 
22
 
23
 package com.dmdirc.addons.osd;
23
 package com.dmdirc.addons.osd;
24
 
24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
49
     /** {@inheritDoc} */
50
     /** {@inheritDoc} */
50
     @Override
51
     @Override
51
     public void execute(final InputWindow origin, final boolean isSilent,
52
     public void execute(final InputWindow origin, final boolean isSilent,
52
-            final String... args) {
53
-        if (args.length > 0 && "--close".equalsIgnoreCase(args[0])) {
53
+            final CommandArguments args) {
54
+        if (args.getArguments().length > 0
55
+                && "--close".equalsIgnoreCase(args.getArguments()[0])) {
54
             OsdWindow.closeAll();
56
             OsdWindow.closeAll();
55
         } else {
57
         } else {
56
-            new OsdWindow(Styliser.stipControlCodes(implodeArgs(args)), false);
58
+            new OsdWindow(Styliser.stipControlCodes(args.getArgumentsAsString()), false);
57
         }
59
         }
58
     }
60
     }
59
     
61
     

+ 3
- 2
src/com/dmdirc/addons/redirect/RedirectCommand.java View File

24
 
24
 
25
 import com.dmdirc.MessageTarget;
25
 import com.dmdirc.MessageTarget;
26
 import com.dmdirc.Server;
26
 import com.dmdirc.Server;
27
+import com.dmdirc.commandparser.CommandArguments;
27
 import com.dmdirc.commandparser.commands.ChatCommand;
28
 import com.dmdirc.commandparser.commands.ChatCommand;
28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
29
 import com.dmdirc.commandparser.commands.IntelligentCommand;
29
 import com.dmdirc.ui.input.AdditionalTabTargets;
30
 import com.dmdirc.ui.input.AdditionalTabTargets;
46
     /** {@inheritDoc} */
47
     /** {@inheritDoc} */
47
     @Override
48
     @Override
48
     public void execute(final InputWindow origin, final Server server,
49
     public void execute(final InputWindow origin, final Server server,
49
-            final MessageTarget target, final boolean isSilent, final String... args) {
50
+            final MessageTarget target, final boolean isSilent, final CommandArguments args) {
50
         target.getFrame().getCommandParser().parseCommand(new FakeInputWindow(target),
51
         target.getFrame().getCommandParser().parseCommand(new FakeInputWindow(target),
51
-                implodeArgs(args));
52
+                args.getArgumentsAsString());
52
     }
53
     }
53
     
54
     
54
     /** {@inheritDoc} */
55
     /** {@inheritDoc} */

+ 3
- 2
src/com/dmdirc/addons/systray/PopupCommand.java View File

23
 package com.dmdirc.addons.systray;
23
 package com.dmdirc.addons.systray;
24
 
24
 
25
 import com.dmdirc.Server;
25
 import com.dmdirc.Server;
26
+import com.dmdirc.commandparser.CommandArguments;
26
 import com.dmdirc.commandparser.CommandManager;
27
 import com.dmdirc.commandparser.CommandManager;
27
 import com.dmdirc.commandparser.commands.ServerCommand;
28
 import com.dmdirc.commandparser.commands.ServerCommand;
28
 import com.dmdirc.ui.interfaces.InputWindow;
29
 import com.dmdirc.ui.interfaces.InputWindow;
52
     /** {@inheritDoc} */
53
     /** {@inheritDoc} */
53
     @Override
54
     @Override
54
     public void execute(final InputWindow origin, final Server server,
55
     public void execute(final InputWindow origin, final Server server,
55
-            final boolean isSilent, final String ... args) {
56
-        parent.notify("DMDirc", implodeArgs(args));
56
+            final boolean isSilent, final CommandArguments args) {
57
+        parent.notify("DMDirc", args.getArgumentsAsString());
57
     }
58
     }
58
 
59
 
59
     /** {@inheritDoc} */
60
     /** {@inheritDoc} */

+ 6
- 5
src/com/dmdirc/addons/time/TimerCommand.java View File

22
 
22
 
23
 package com.dmdirc.addons.time;
23
 package com.dmdirc.addons.time;
24
 
24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.CommandManager;
26
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.commandparser.commands.GlobalCommand;
27
 import com.dmdirc.commandparser.commands.IntelligentCommand;
28
 import com.dmdirc.commandparser.commands.IntelligentCommand;
47
     /** {@inheritDoc} */
48
     /** {@inheritDoc} */
48
     @Override
49
     @Override
49
     public void execute(final InputWindow origin, final boolean isSilent, 
50
     public void execute(final InputWindow origin, final boolean isSilent, 
50
-            final String... args) {
51
-        if (args.length < 3) {
51
+            final CommandArguments args) {
52
+        if (args.getArguments().length < 3) {
52
             doUsage(origin, isSilent);
53
             doUsage(origin, isSilent);
53
         } else {
54
         } else {
54
             int repetitions = 0;
55
             int repetitions = 0;
55
             int interval = 0;
56
             int interval = 0;
56
-            final String command = implodeArgs(2, args);
57
+            final String command = args.getArgumentsAsString(2);
57
             
58
             
58
             try {
59
             try {
59
-                repetitions = Integer.parseInt(args[0]);
60
-                interval = Integer.parseInt(args[1]);
60
+                repetitions = Integer.parseInt(args.getArguments()[0]);
61
+                interval = Integer.parseInt(args.getArguments()[1]);
61
             } catch (NumberFormatException ex) {
62
             } catch (NumberFormatException ex) {
62
                 doUsage(origin, isSilent);
63
                 doUsage(origin, isSilent);
63
                 return;
64
                 return;

+ 2
- 1
src/com/dmdirc/addons/urlcatcher/UrlListCommand.java View File

22
 
22
 
23
 package com.dmdirc.addons.urlcatcher;
23
 package com.dmdirc.addons.urlcatcher;
24
 
24
 
25
+import com.dmdirc.commandparser.CommandArguments;
25
 import com.dmdirc.commandparser.commands.GlobalCommand;
26
 import com.dmdirc.commandparser.commands.GlobalCommand;
26
 import com.dmdirc.commandparser.commands.IntelligentCommand;
27
 import com.dmdirc.commandparser.commands.IntelligentCommand;
27
 import com.dmdirc.ui.input.AdditionalTabTargets;
28
 import com.dmdirc.ui.input.AdditionalTabTargets;
44
     /** {@inheritDoc} */
45
     /** {@inheritDoc} */
45
     @Override
46
     @Override
46
     public void execute(final InputWindow origin, final boolean isSilent,
47
     public void execute(final InputWindow origin, final boolean isSilent,
47
-            final String... args) {
48
+            final CommandArguments args) {
48
         final String[] headers = {"URL", "Count"};
49
         final String[] headers = {"URL", "Count"};
49
         final Map<String, Integer> map = plugin.getURLS();
50
         final Map<String, Integer> map = plugin.getURLS();
50
         final String[][] data = new String[map.size()][];
51
         final String[][] data = new String[map.size()][];

+ 15
- 1
src/com/dmdirc/commandparser/CommandArguments.java View File

108
     public String getArgumentsAsString() {
108
     public String getArgumentsAsString() {
109
         parse();
109
         parse();
110
         
110
         
111
-        return getWordsAsString(1);
111
+        return getArgumentsAsString(0);
112
+    }
113
+
114
+    /**
115
+     * Retrieves arguments to the command (i.e., not including the
116
+     * command name) starting with the specified argument, with their original
117
+     * whitespace separation preserved.
118
+     *
119
+     * @param start The index of the first argument to include
120
+     * @return A String representation of the command arguments
121
+     */
122
+    public String getArgumentsAsString(final int start) {
123
+        parse();
124
+
125
+        return getWordsAsString(start + 1);
112
     }
126
     }
113
 
127
 
114
     /**
128
     /**

Loading…
Cancel
Save