From eac140ad429179cfef8d90a34cf6d429b7e80983 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Fri, 9 Oct 2015 13:50:02 -0700 Subject: [PATCH 1/2] Add usage example for gcloud-java-examples --- gcloud-java-examples/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index e70384a1bf92..6c14fd12765c 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -20,6 +20,33 @@ Add this to your pom.xml file ``` +To run examples from your command line: + +1. Login using gcloud SDK (`gcloud auth login` in command line) + +2. Compile using Maven (`mvn compile` in command line from your base project directory) + +3. Run an example using Maven from command line. + + Here's an example run of `DatastoreExample`. + + Note that you have to enable the Google Cloud Datastore API on the [Google Developers Console][developers-console] before running the following commands. + ``` + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="[] [user] add my\ comment" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="[] [user] display" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="[] [user] delete" + ``` + + Here's an example run of `StorageExample`. + + Before running the example, go to the [Google Developers Console][developers-console] to ensure that Google Cloud Storage API is enabled and that you have a bucket. Also ensure that you have a test file (`test.txt` is chosen here) to upload to Cloud Storage stored locally on your machine. + ``` + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args=" upload /path/to/test.txt " + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args=" list " + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args=" download test.txt" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args=" delete test.txt" +``` + Contributing ------------ @@ -50,3 +77,4 @@ Apache 2.0 - See [LICENSE] for more information. [CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md [LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE [cloud-platform]: https://cloud.google.com/ +[developers-console]:https://console.developers.google.com/ From 494cd91d601b7063e28c30dabaca9f857fcc3f01 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Fri, 9 Oct 2015 15:52:09 -0700 Subject: [PATCH 2/2] shorten usage example by using gcloud sdk set project --- gcloud-java-examples/README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index 6c14fd12765c..991e0ef5fd91 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -24,27 +24,29 @@ To run examples from your command line: 1. Login using gcloud SDK (`gcloud auth login` in command line) -2. Compile using Maven (`mvn compile` in command line from your base project directory) +2. Set your current project using `gcloud config set project PROJECT_ID` -3. Run an example using Maven from command line. +3. Compile using Maven (`mvn compile` in command line from your base project directory) + +4. Run an example using Maven from command line. Here's an example run of `DatastoreExample`. Note that you have to enable the Google Cloud Datastore API on the [Google Developers Console][developers-console] before running the following commands. ``` - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="[] [user] add my\ comment" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="[] [user] display" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="[] [user] delete" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="my_name add my\ comment" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="my_name display" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DatastoreExample" -Dexec.args="my_name delete" ``` Here's an example run of `StorageExample`. Before running the example, go to the [Google Developers Console][developers-console] to ensure that Google Cloud Storage API is enabled and that you have a bucket. Also ensure that you have a test file (`test.txt` is chosen here) to upload to Cloud Storage stored locally on your machine. ``` - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args=" upload /path/to/test.txt " - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args=" list " - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args=" download test.txt" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args=" delete test.txt" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="upload /path/to/test.txt " + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="list " + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="download test.txt" + $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="delete test.txt" ``` Contributing