tasks = formatTasks(listTasks());
+ System.out.printf("found %d tasks:%n", tasks.size());
+ System.out.println("task ID : description");
+ System.out.println("---------------------");
+ for (String taskString : tasks) {
+ System.out.println(taskString);
+ }
+ break;
+ case "delete":
+ assertArgsLength(args, 2);
+ deleteTask(Long.parseLong(args[1]));
+ System.out.println("task deleted");
+ break;
+ default:
+ throw new IllegalArgumentException("unrecognized command: " + command);
+ }
+ }
+
+ private void assertArgsLength(String[] args, int expectedLength) {
+ if (args.length != expectedLength) {
+ throw new IllegalArgumentException(
+ String.format("expected exactly %d arg(s), found %d", expectedLength, args.length));
+ }
+ }
+
+ /**
+ * Exercises the methods defined in this class.
+ *
+ * Assumes that you are authenticated using the Google Cloud SDK (using
+ * {@code gcloud auth login}).
+ */
+ public static void main(String[] args) throws Exception {
+ TaskList taskList = new TaskList();
+ System.out.println("Cloud Datastore Task List");
+ System.out.println();
+ printUsage();
+ while (true) {
+ String commandLine = System.console().readLine("> ");
+ if (commandLine.trim().isEmpty()) {
+ break;
+ }
+ try {
+ taskList.handleCommandLine(commandLine);
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ printUsage();
+ }
+ }
+ System.out.println("exiting");
+ System.exit(0);
+ }
+
+ private static void printUsage() {
+ System.out.println("Usage:");
+ System.out.println();
+ System.out.println(" new Adds a task with a description ");
+ System.out.println(" done Marks a task as done");
+ System.out.println(" list Lists all tasks by creation time");
+ System.out.println(" delete Deletes a task");
+ System.out.println();
+ }
+}
diff --git a/pom.xml b/pom.xml
index c8f6370685d..1fac8254359 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,6 +40,7 @@
managed_vms/async-rest
managed_vms/sparkjava
bigquery
+ datastore
logging
monitoring
storage/json-api