Skip to content
Snippets Groups Projects
Commit fcd70346 authored by Jack MacLauchlan CS2015's avatar Jack MacLauchlan CS2015
Browse files

attachment cli commands done

parent 7653aa51
No related branches found
No related tags found
1 merge request!2Commit tree
......@@ -117,6 +117,15 @@ public class CommandLineInterface {
.build();
uniqueCommands.addOption(addAssignee);
Option attachment = Option.builder()
.longOpt("attachment")
.hasArgs()
.numberOfArgs(3)
.argName("ID> <OPTION> <DATA")
.desc("add or delete attachment to issue with given id, option values: \"add\" & \"rm\"")
.build();
uniqueCommands.addOption(attachment);
options.addOptionGroup(uniqueCommands);
}
......
package command;
public interface Command {
interface Command {
void execute();
}
package command;
import git.IssueRepo;
import issueData.User;
import java.io.File;
import java.io.IOException;
......@@ -13,7 +12,7 @@ public final class CommandAttachment implements Command {
private final String option;
private final String path;
public CommandAttachment(String[] args) {
CommandAttachment(String[] args) {
this.hash = args[0];
this.option = args[1];
this.path = args[2];
......@@ -36,7 +35,7 @@ public final class CommandAttachment implements Command {
break;
case "rm":
boolean success = issue.getAttatchment().removeIf(f -> f.getName().equals(path));
if (success){
if (success) {
commitMessage = "attachment " + path + " removed from issue " + hash;
System.out.println("Attachment removed");
} else {
......
......@@ -43,7 +43,9 @@ public class CommandSelector {
command = watcher(userInput.getOptionValues("watcher"));
} else if(userInput.hasOption("assignee")){
command = assignee(userInput.getOptionValues("assignee"));
} else {
} else if(userInput.hasOption("attachment")) {
command = attachment(userInput.getOptionValues("attachment"));
}else {
commandLineInterface.help();
command = nullCommand();
}
......@@ -98,6 +100,10 @@ public class CommandSelector {
return new CommandTag(args);
}
private Command attachment(String[] args) {
return new CommandAttachment(args);
}
private Command assignee(String[] args) { return new CommandAssign(args);}
private Command watcher(String[] args) { return new CommandWatcher(args);}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment