diff --git a/src/cmds/cloud/createThing.js b/src/cmds/cloud/createThing.js index 91acf6b..78f5757 100644 --- a/src/cmds/cloud/createThing.js +++ b/src/cmds/cloud/createThing.js @@ -36,7 +36,13 @@ yargs _yargs .options(options.amqp) .options(options.http) - .options(options.basic); + .options(options.basic) + .example([ + [ + '$0 create-thing 0c2958525df5dc3c thing-example --amqp-server api.fog ', + 'Create a new thing with id `0c2958525df5dc3c` and name `thing-example`.', + ], + ]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/createToken.js b/src/cmds/cloud/createToken.js index 97891e2..7f1cefb 100644 --- a/src/cmds/cloud/createToken.js +++ b/src/cmds/cloud/createToken.js @@ -1,4 +1,4 @@ -/* eslint-disable no-console */ +/* eslint-disable no-console, no-multi-str */ import yargs from 'yargs'; import chalk from 'chalk'; import { Authenticator } from '@cesarbr/knot-cloud-sdk-js'; @@ -18,7 +18,17 @@ yargs.command({ command: 'create-token ', desc: 'Create a new user or app token', builder: (_yargs) => { - _yargs.options(options.http); + _yargs.options(options.http).example([ + [ + '$0 create-token knot@knot.com strong@password! user --http-server api.fog', + 'Create a new `user` token for the `knot@knot.com` user.', + ], + [ + '$0 create-token knot@knot.com app --http-server api.fog', + 'Create a new `app` token for the `knot@knot.com` user. The \ + `user` token previously created must by passed as password for creating an `app` token.', + ], + ]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/createUser.js b/src/cmds/cloud/createUser.js index 5f8423f..3aafd5f 100644 --- a/src/cmds/cloud/createUser.js +++ b/src/cmds/cloud/createUser.js @@ -39,7 +39,13 @@ yargs.command({ desc: 'Create a new user', builder: (_yargs) => { _yargs - .options(options.http); + .options(options.http) + .example([ + [ + '$0 create-user knot@knot.com strong@password! --http-server api.fog', + 'Create a new user with e-mail `knot@knot.com` and password `strong@password!`', + ], + ]); }, handler: async (args) => { await createUser(args); diff --git a/src/cmds/cloud/deleteThing.js b/src/cmds/cloud/deleteThing.js index 84a8fa6..0389e5f 100644 --- a/src/cmds/cloud/deleteThing.js +++ b/src/cmds/cloud/deleteThing.js @@ -39,7 +39,13 @@ yargs .options(options.basic) .positional('id', { describe: 'Thing ID', - }); + }) + .example([ + [ + '$0 delete-thing 0c2958525df5dc3c --amqp-server api.fog --token ', + 'Delete the thing `0c2958525df5dc3c`.', + ], + ]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/getData.js b/src/cmds/cloud/getData.js index 8645314..cad0c82 100644 --- a/src/cmds/cloud/getData.js +++ b/src/cmds/cloud/getData.js @@ -42,7 +42,13 @@ yargs }) .positional('sensor-id', { describe: 'ID of the sensor to request the data', - }); + }) + .example([ + [ + '$0 get-data 0c2958525df5dc3c 0 --amqp-server api.fog --token ', + 'Request a new data sample from the sensor `0` of thing `0c2958525df5dc3c`.', + ], + ]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/listThings.js b/src/cmds/cloud/listThings.js index e1c1b22..ee5342d 100644 --- a/src/cmds/cloud/listThings.js +++ b/src/cmds/cloud/listThings.js @@ -59,7 +59,13 @@ yargs _yargs .options(options.amqp) .options(options.http) - .options(options.basic); + .options(options.basic) + .example([ + [ + '$0 list-things --amqp-server api.fog --token ', + 'List the registered things.', + ], + ]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/publishData.js b/src/cmds/cloud/publishData.js index 2bc6b96..b4f73a4 100644 --- a/src/cmds/cloud/publishData.js +++ b/src/cmds/cloud/publishData.js @@ -57,7 +57,13 @@ yargs return parseFloat(value); }, - }); + }) + .example([ + [ + '$0 publish-data 0c2958525df5dc3c 0 true --amqp-server api.fog --token ', + 'Publish the value `true` as the sensor `0` on behalf of thing `0c2958525df5dc3c`.', + ], + ]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/setData.js b/src/cmds/cloud/setData.js index 7f2098b..be7606b 100644 --- a/src/cmds/cloud/setData.js +++ b/src/cmds/cloud/setData.js @@ -65,7 +65,13 @@ yargs return parseFloat(value); }, - }); + }) + .example([ + [ + '$0 set-data 0c2958525df5dc3c 0 true --amqp-server api.fog --token ', + 'Set a custom value `true` to the sensor `0` of thing `0c2958525df5dc3c`.', + ], + ]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/signin.js b/src/cmds/cloud/signin.js index 3e25045..926d438 100644 --- a/src/cmds/cloud/signin.js +++ b/src/cmds/cloud/signin.js @@ -1,4 +1,4 @@ -/* eslint-disable no-console */ +/* eslint-disable no-console, no-multi-str */ import yargs from 'yargs'; import { Authenticator } from '@cesarbr/knot-cloud-sdk-js'; import os from 'os'; @@ -71,7 +71,14 @@ yargs.command({ .positional('password', { describe: "User's password", demandOption: true, - }); + }) + .example([ + [ + '$0 login --http-server api.fog', + 'Login to the KNoT Cloud and create a token that will automatically be imported by the \ + operations.', + ], + ]); }, handler: async (args) => { login(args); diff --git a/src/cmds/cloud/subscribe.js b/src/cmds/cloud/subscribe.js index ee8057c..e382f99 100644 --- a/src/cmds/cloud/subscribe.js +++ b/src/cmds/cloud/subscribe.js @@ -37,7 +37,8 @@ yargs _yargs .options(options.amqp) .options(options.http) - .options(options.basic); + .options(options.basic) + .example([['$0 on data --http-server api.fog', 'Subscribe for receiving `data` events.']]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/updateConfig.js b/src/cmds/cloud/updateConfig.js index 559d117..0983041 100644 --- a/src/cmds/cloud/updateConfig.js +++ b/src/cmds/cloud/updateConfig.js @@ -50,7 +50,13 @@ yargs }) .options(options.amqp) .options(options.http) - .options(options.basic); + .options(options.basic) + .example([ + [ + '$0 update-config /config.json --amqp-server api.fog --token $USER_TOKEN', + 'Update thing `9d3b2e867d483c80` sensor `0` config, which is imported from a JSON file.', + ], + ]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/updateConfigEvent.js b/src/cmds/cloud/updateConfigEvent.js index 70cc151..c3f47c8 100644 --- a/src/cmds/cloud/updateConfigEvent.js +++ b/src/cmds/cloud/updateConfigEvent.js @@ -1,4 +1,4 @@ -/* eslint-disable no-console */ +/* eslint-disable no-console, no-multi-str */ import yargs from 'yargs'; import fs from 'fs'; import chalk from 'chalk'; @@ -87,7 +87,15 @@ yargs describe: 'send data to the cloud if it is upper than this threshold', demandOption: false, default: 3000, - }); + }) + .example([ + [ + '$0 update-config-event 9d3b2e867d483c80 0 true 10 3000 4000 \ + --amqp-server api.fog --token ', + 'Update thing `9d3b2e867d483c80` sensor `0` config event with \ + change=true, timeSec=10, lowerThreshold=3000, upperThreshold=4000', + ], + ]); }, handler: async (args) => { try { diff --git a/src/cmds/cloud/updateConfigSchema.js b/src/cmds/cloud/updateConfigSchema.js index f1fd2a9..412cb1e 100644 --- a/src/cmds/cloud/updateConfigSchema.js +++ b/src/cmds/cloud/updateConfigSchema.js @@ -1,4 +1,4 @@ -/* eslint-disable no-console */ +/* eslint-disable no-console, no-multi-str */ import yargs from 'yargs'; import fs from 'fs'; import chalk from 'chalk'; @@ -86,7 +86,15 @@ yargs describe: 'Sensor name', demandOption: false, default: 'Development Thing', - }); + }) + .example([ + [ + '$0 update-config-schema 9d3b2e867d483c80 0 2 0 65521 light-bulb \ + --amqp-server api.fog --token $USER_TOKEN', + 'Update thing `9d3b2e867d483c80` sensor `0` config schema with \ + valueType=2, unit=0, typeId=65521, name=light-bulb', + ], + ]); }, handler: async (args) => { try {