package com.tmitim.twittercli.commands;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.github.rvesse.airline.SingleCommand;
import com.github.rvesse.airline.annotations.Arguments;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;

import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;

/**
 * Tweet to twitter
 *
 */
@Command(name = "tweet", description = "Tweet your thoughts")
public class Tweet implements Runnable {

	@Option(name = { "-f", "--flag" }, description = "An option that requires no values")
	private boolean flag = false;

	@Arguments(description = "Additional arguments")
	private List<String> args;

	public static void main(String[] args) {
		SingleCommand<Tweet> parser = SingleCommand.singleCommand(Tweet.class);
		Tweet cmd = parser.parse(args);
		cmd.run();
	}

	public void run() {
		Twitter twitter = TwitterFactory.getSingleton();

		try {
			Status status = twitter.updateStatus(StringUtils.join(args, " "));
			System.out.println("Successfully updated the status to [" + status.getText() + "].");

		} catch (TwitterException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		System.out.println("Flag was " + (this.flag ? "set" : "not set"));
		if (args != null)
			System.out.println("Arguments were " + StringUtils.join(args, " "));
	}
}
@@ -266,62 +266,8 @@
 nd;%0A
-import com.github.rvesse.airline.annotations.Option;%0A%0A
 impo
@@ -521,127 +521,8 @@
  %7B%0A%0A
-%09@Option(name = %7B %22-f%22, %22--flag%22 %7D, description = %22An option that requires no values%22)%0A%09private boolean flag = false;%0A%0A
 %09@Ar
@@ -763,16 +763,27 @@
 ();%0A%09%7D%0A%0A
+%09@Override%0A
 %09public 
@@ -1055,232 +1055,32 @@
 %0A%09%09%09
-// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%0A%09%09System.out.println(%22Flag was %22 + (this.flag ? %22set%22 : %22not set%22));%0A%09%09if (args != null)%0A%09%09%09System.out.println(%22Arguments were %22 + StringUtils.join(args, %22 %22));
+e.printStackTrace();%0A%09%09%7D
 %0A%09%7D%0A

Remove unused argument/flag when tweeting