diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5fb73c807..0e7713f4ee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,6 +27,65 @@ accept your pull requests. 1. Fork the desired repo, develop and test your code changes. 1. Ensure that your code adheres to the existing style in the sample to which you are contributing. Refer to the [Google Cloud Platform Samples Style Guide](https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the - recommended coding standards for this organization. You can run `npm run jshint` to match our JavaScript coding standards. + recommended coding standards for this organization. You can run `npm run jshint` to match our JavaScript coding standards. 1. Ensure that your code has an appropriate set of unit tests which all pass. 1. Submit a pull request! + +## Sample template + +``` + + +// [START all] +// [START setup] +// By default, the client will authenticate using the service account file +// specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use +// the project specified by the GCLOUD_PROJECT environment variable. See +// https://googlecloudplatform.github.io/gcloud-node/#/docs/google-cloud/latest/guides/authentication +var = require('@google-cloud/'); + +// Instantiate a client +var = (); +// [END setup] + +// [START ] +/** + * + * + * @param {} . + * @param {function} cb The callback function. + */ +function (, callback) { + // + + // + + // Inside callback: console.log() +} +// [END ] + +// The command-line program +var cli = require('yargs'); + +var program = module.exports = { + : , + main: function (args) { + // Run the command-line program + cli.help().strict().parse(args).argv; + } +}; + +cli + .demand(1) + .command(' ', '.', {}, function (options) { + program.(options, console.log); + }) + .example('node $0 ', '.') + .wrap(100) + .recommendCommands() + .epilogue('For more information, see '); + +if (module === require.main) { + program.main(process.argv.slice(2)); +} +``` \ No newline at end of file diff --git a/storage/README.md b/storage/README.md index a5a54eb01b..3af203b46b 100644 --- a/storage/README.md +++ b/storage/README.md @@ -42,11 +42,12 @@ Commands: delete Delete access controls from a bucket or file. Options: - --bucket, -b The target storage bucket. [string] [required] - --default, -d Whether to set default access controls. Only valid when setting access controls on - a bucket. [boolean] - --file, -f The target file. [string] - --help Show help [boolean] + --bucket, -b The target storage bucket. [string] [required] + --default, -d Whether to set default access + controls. Only valid when setting + access controls on a bucket. [boolean] + --file, -f The target file. [string] + --help Show help [boolean] Examples: node acl add user-bob@domain.com OWNER -b mybucket Add OWNER access controls for @@ -71,19 +72,20 @@ View the [documentation][buckets_docs] or the [source code][buckets_code]. __Usage:__ `node buckets --help` ``` -Usage: node buckets COMMAND [ARGS...] - Commands: + create Create a new bucket with the given name. + list List all buckets in the authenticated project. + delete Delete the specified bucket. - create BUCKET_NAME - list - delete BUCKET_NAME +Options: + --help Show help [boolean] Examples: + node buckets create my-bucket Create a new bucket named "my-bucket". + node buckets list List all buckets in the authenticated project. + node buckets delete my-bucket Delete "my-bucket". - node buckets create my-bucket - node buckets list - node buckets delete my-bucket +For more information, see https://cloud.google.com/storage/docs ``` [buckets_docs]: https://cloud.google.com/storage/docs @@ -96,21 +98,25 @@ View the [documentation][encryption_docs] or the [source code][encryption_code]. __Usage:__ `node encryption --help` ``` -Usage: node encryption COMMAND [ARGS...] - Commands: + generate-encryption-key Generate a sample encryption key. + upload Upload an encrypted file to a bucket. + download Download an encrypted file from a bucket. + rotate Rotate encryption keys for a file. - generate-encryption-key - upload BUCKET_NAME SRC_FILE_NAME DEST_FILE_NAME KEY - download BUCKET_NAME SRC_FILE_NAME DEST_FILE_NAME KEY - rotate BUCKET_NAME FILE_NAME OLD_KEY NEW_KEY +Options: + --help Show help [boolean] Examples: - - node encryption generate-encryption-key - node encryption upload my-bucket resources/test.txt file_encrypted.txt QxhqaZEqBGVTW55HhQw9Q= - node encryption download my-bucket file_encrypted.txt ./file.txt QxhqaZEqBGVTW55HhQw9Q= - node encryption rotate my-bucket file_encrypted.txt QxhqaZEqBGVTW55HhQw9Q= SxafpsdfSDFS89sds9Q= + node encryption generate-encryption-key Generate a sample encryption key. + node encryption upload my-bucket resources/test.txt Upload "resources/test.txt" to + file_encrypted.txt QxhqaZEqBGVTW55HhQw9Q= "gs://my-bucket/file_encrypted.txt". + node encryption download my-bucket file_encrypted.txt Download "gs://my-bucket/file_encrypted.txt" to + ./file.txt QxhqaZEqBGVTW55HhQw9Q= "./file.txt". + node encryption rotate my-bucket file_encrypted.txt Rotate encryptiong keys for + QxhqaZEqBGVTW55HhQw9Q= SxafpsdfSDFS89sds9Q= "gs://my-bucket/file_encrypted.txt". + +For more information, see https://cloud.google.com/storage/docs ``` [encryption_docs]: https://cloud.google.com/storage/docs @@ -123,32 +129,36 @@ View the [documentation][files_docs] or the [source code][files_code]. __Usage:__ `node files --help` ``` -Usage: node files COMMAND [ARGS...] - Commands: + list [options] List files in a bucket, optionally filtering + by a prefix. + upload Upload a local file to a bucket. + download Download a file from a bucket. + delete Delete a file from a bucket. + getMetadata Get metadata for a file in a bucket. + makePublic Make a file public in a bucket. + move Rename a file in a bucket. + copy Copy a file in a bucket to another bucket. - list BUCKET_NAME - listByPrefix BUCKET_NAME PREFIX [DELIMITER] - upload BUCKET_NAME FILE_NAME - download BUCKET_NAME SRC_FILE_NAME DEST_FILE_NAME - delete BUCKET_NAME FILE_NAME - getMetadata BUCKET_NAME FILE_NAME - makePublic BUCKET_NAME FILE_NAME - move BUCKET_NAME SRC_FILE_NAME DEST_FILE_NAME - copy BUCKET_NAME SRC_FILE_NAME DEST_BUCKET_NAME DEST_FILE_NAME +Options: + --help Show help [boolean] Examples: - - list my-bucket - listByPrefix my-bucket /some-folder - listByPrefix my-bucket /some-folder - - upload my-bucket ./file.txt - download my-bucket file.txt ./file.txt - delete my-bucket file.txt - getMetadata my-bucket file.txt - makePublic my-bucket file.txt - move my-bucket file.txt file2.txt - copy my-bucket file.txt my-other-bucket file.txt + node files list my-bucket List files in "my-bucket". + node files list my-bucket -p public/ List files in "my-bucket" filtered by prefix + "public/". + node files upload my-bucket ./file.txt Upload "./file.txt" to "my-bucket". + node files download my-bucket file.txt ./file.txt Download "gs://my-bucket/file.txt" to + "./file.txt". + node files delete my-bucket file.txt Delete "gs://my-bucket/file.txt". + node files getMetadata my-bucket file.txt Get metadata for "gs://my-bucket/file.txt". + node files makePublic my-bucket file.txt Make "gs://my-bucket/file.txt" public. + node files move my-bucket file.txt file2.txt Rename "gs://my-bucket/file.txt" to + "gs://my-bucket/file2.txt". + node files copy my-bucket file.txt my-other-bucket Copy "gs://my-bucket/file.txt" to + file.txt "gs://my-other-bucket/file.txt". + +For more information, see https://cloud.google.com/storage/docs ``` [files_docs]: https://cloud.google.com/storage/docs @@ -161,41 +171,74 @@ View the [documentation][storagetransfer_docs] or the [source code][storagetrans __Usage:__ `node transfer --help` ``` -Usage: node encryption RESOURCE COMMAND [ARGS...] +Commands: + jobs [args] Run a job command. + operations [args] Run an operation command. -Resources: +Options: + --help Show help [boolean] - jobs +Examples: + node transfer jobs --help Show job commands. + node transfer operations --help Show operations commands. - Commands: +For more information, see https://cloud.google.com/storage/transfer +``` - create SRC_BUCKET_NAME DEST_BUCKET_NAME DATE TIME [DESCRIPTION] - get JOB_NAME - list - set JOB_NAME FIELD VALUE +__Usage:__ `node transfer jobs --help` - operations +``` +transfer jobs [args] - Commands: +Commands: + create