@@ -0,0 +1,2105 @@
+package tars.logic.commands;%0A%0Aimport static tars.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;%0A%0Aimport javafx.collections.ObservableList;%0Aimport tars.commons.exceptions.IllegalValueException;%0Aimport tars.commons.flags.Flag;%0Aimport tars.model.tag.ReadOnlyTag;%0Aimport tars.model.tag.Tag;%0Aimport tars.model.tag.UniqueTagList.TagNotFoundException;%0Aimport tars.ui.Formatter;%0A%0A/**%0A * Tag a task identified using it's last displayed index from tars.%0A */%0Apublic class TagCommand extends Command %7B%0A%0A    public static final String COMMAND_WORD = %22tag%22;%0A%0A    public static final String MESSAGE_USAGE = COMMAND_WORD + %22: %5B-ls%5D %5B-e %3CINDEX%3E %3CTAG%3E%5D%22;%0A    %0A    public static final String MESSAGE_RENAME_TAG_SUCCESS = %22%251$s renamed to %5B%252$s%5D%22;%0A%0A    private Flag flag;%0A    private String%5B%5D args;%0A    %0A    public TagCommand(Flag flag) %7B%0A        this.flag = flag;%0A    %7D%0A    %0A    public TagCommand(Flag flag, String%5B%5D args) %7B%0A        this.flag = flag;%0A        this.args = args;%0A    %7D%0A%0A    @Override%0A    public CommandResult execute() %7B%0A        if (flag.prefix.equals(Flag.LIST)) %7B%0A            ObservableList%3C? extends ReadOnlyTag%3E allTags = model.getUniqueTagList();%0A            return new CommandResult(new Formatter().formatTags(allTags));%0A        %7D else if (flag.prefix.equals(Flag.EDIT)) %7B%0A            try %7B%0A                int index = Integer.parseInt(args%5B0%5D);%0A                String newTagName = args%5B1%5D;%0A%0A                ReadOnlyTag toBeRename = model.getUniqueTagList().get(index - 1);%0A                model.renameTag(toBeRename, newTagName);%0A                return new CommandResult(String.format(String.format(MESSAGE_RENAME_TAG_SUCCESS,%0A                        toBeRename.getAsText(), newTagName)));%0A            %7D catch (IllegalValueException e) %7B%0A                return new CommandResult(Tag.MESSAGE_TAG_CONSTRAINTS);%0A            %7D catch (TagNotFoundException e) %7B%0A                return new CommandResult(e.getMessage());%0A            %7D%0A        %7D else %7B%0A            return new CommandResult(%0A                    String.format(MESSAGE_INVALID_COMMAND_FORMAT, TagCommand.MESSAGE_USAGE));%0A        %7D%0A    %7D%0A%0A%7D%0A

Add new tag command