diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c7c4844804..f07f3cddc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -138,59 +138,68 @@ You can run `npm run lint` to match our JavaScript coding standards. ## 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 ] +```js /** - * + * Copyright 2017, Google, Inc. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * @param {} . - * @param {function} cb The callback function. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -function (, callback) { - // - - // - // Inside callback: console.log() +'use strict'; + +function someMethod (someVariable) { + // [START some_region_tag] + // Imports the Google Cloud client library + const Library = require('@google-cloud/some-library'); + + // The something something, e.g. "some-value" + // const someVariable = "some-value"; + + // Instantiates a client + const library = Library(); + + // Does something + library + .someMethod(someVariable) + .then((results) => { + const someResults = results[0]; + + console.log('Results:'); + someResults.forEach((result) => { + console.log(result); + }); + }) + .catch((err) => { + console.error('ERROR:', err); + }); + // [END some_region_tag] } -// [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; // eslint-disable-line - } -}; -cli +const cli = require('yargs') .demand(1) - .command(' ', '.', {}, function (options) { - program.(options, console.log); - }) - .example('node $0 ', '.') - .wrap(100) + .command( + 'someCommand ', + 'Does something.', + {}, + (opts) => someMethod(opts.someVariable) + ) + .example('node $0 someCommand someValue', 'Does something.') + .wrap(120) .recommendCommands() - .epilogue('For more information, see '); + .epilogue(`For more information, see https://cloud.google.com/someProduct/docs`) + .help() + .strict(); if (module === require.main) { - program.main(process.argv.slice(2)); + cli.parse(process.argv.slice(2)); } ```