package com.tmitim.twittercli;

import java.util.ArrayList;
import java.util.List;

import com.github.rvesse.airline.annotations.Command;

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

/**
 * Get timeline
 */
@Command(name = "timeline", description = "Get your timeline")
public class TimeLine implements Runnable {

	public void run() {

		System.out.println("Pulling your timeline.");
		Twitter twitter = TwitterFactory.getSingleton();

		List<Status> statuses = new ArrayList<>();
		try {
			statuses = twitter.getHomeTimeline();
		} catch (TwitterException e) {
			e.printStackTrace();
		}
		for (Status status : statuses) {
			System.out.println(status.getUser().getName() + " (@" + status.getUser().getScreenName() + "): ");
			System.out.println(status.getText());
			System.out.println(status.getCreatedAt());
			System.out.println(
				String.format(
					"ID: %d, RT: %d, <3: %d",
					status.getId(),
					status.getRetweetCount(),
					status.getFavoriteCount()
				)
			);
			System.out.println("");
		}
	}
}
@@ -53,16 +53,46 @@
 ayList;%0A
+import java.util.Collections;%0A
 import j
@@ -160,16 +160,69 @@
 Command;
+%0Aimport com.github.rvesse.airline.annotations.Option;
 %0A%0Aimport
@@ -472,77 +472,215 @@
 %7B%0A%0A%09
-public void run() %7B%0A%0A%09%09System.out.println(%22Pulling your timeline.%22);%0A
+@Option(name = %7B %22-u%22, %22--user%22 %7D, description = %22get the timeline for a specific username%22)%0A%09private String username;%0A%0A%09@Override%0A%09public void run() %7B%0A%0A%09%09List%3CStatus%3E statuses = new ArrayList%3C%3E();%0A%09%09try %7B%0A%09
 %09%09Tw
@@ -730,62 +730,247 @@
 ();%0A
-%0A%09%09List%3CStatus%3E statuses = new ArrayList%3C%3E();%0A%09%09try %7B%0A
+%09%09%09if ( username != null && !username.isEmpty() ) %7B%0A%09%09%09%09System.out.println(%22Pulling @%22 + username + %22's timeline...%22);%0A%09%09%09%09statuses = twitter.getUserTimeline(username);%0A%09%09%09%7D else %7B%0A%09%09%09%09System.out.println(%22Pulling your home timeline...%22);%0A%09
 %09%09%09s
@@ -1006,16 +1006,21 @@
 line();%0A
+%09%09%09%7D%0A
 %09%09%7D catc
@@ -1051,32 +1051,86 @@
 %0A%09%09%09
-e.printStackTrac
+System.out.println(e.getErrorMessag
 e()
+)
 ;%0A%09%09%7D
+%0A%0A%09%09Collections.reverse(statuses);
 %0A%09%09f

Add flag to get specific user's timeline