Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Commit 0a8284e

Browse files
author
Nick Cook
committed
Add help text to devicetool commands.
Change-Id: Ide6341ef85919e59d43152d68e3c8c0819dcb9a2 Bug: 67367104
1 parent 1758648 commit 0a8284e

File tree

1 file changed

+119
-23
lines changed

1 file changed

+119
-23
lines changed

google-assistant-sdk/googlesamples/assistant/grpc/devicetool.py

Lines changed: 119 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,34 @@ def failed_request_exception(message, r):
4141

4242

4343
@click.group()
44-
@click.option('--project')
45-
@click.option('--client-secret')
44+
@click.option('--project',
45+
help='Enter the Google Developer Project ID that you want to '
46+
'use with the registration tool. If you don\'t use this flag, '
47+
'the tool will use the project listed in the '
48+
'<client_secret_client-id.json> file you specify with the '
49+
'--client-secret flag.')
50+
@click.option('--client-secret',
51+
help='Enter the path and filename for the '
52+
'<client_secret_client-id.json> file you downloaded from your '
53+
'developer project. This file is used to infer the Google '
54+
'Developer Project ID if it was not provided with the --project '
55+
'flag. If the --project flag and this flag are not used, the '
56+
'tool will look for this file in the current directory (by '
57+
'searching for a file named after the client_id stored in the '
58+
'credentials file).')
4659
@click.option('--api-endpoint', default='embeddedassistant.googleapis.com',
47-
show_default=True)
60+
show_default=True,
61+
help='Hostname for the Google Assistant API. Do not use this '
62+
'flag unless explicitly instructed.')
4863
@click.option('--credentials', show_default=True,
4964
default=os.path.join(click.get_app_dir('google-oauthlib-tool'),
50-
'credentials.json'))
65+
'credentials.json'),
66+
help='File location of the generated credentials file. The '
67+
'google-oauthlib-tool generates this file after authorizing '
68+
'the user with the <client_secret_client-id.json> file. This '
69+
'credentials file authorizes access to the Google Assistant '
70+
'API. You can use this flag if the credentials were generated '
71+
'in a location that is different than the default.')
5172
@click.pass_context
5273
def cli(ctx, project, client_secret, api_endpoint, credentials):
5374
try:
@@ -82,18 +103,47 @@ def cli(ctx, project, client_secret, api_endpoint, credentials):
82103

83104

84105
@cli.command()
85-
@click.option('--model', required=True)
106+
@click.option('--model', required=True,
107+
help='Enter a globally-unique identifier for this device model; '
108+
'you should use your project ID as a prefix to help avoid '
109+
'collisions over the range of all projects (for example, '
110+
'"my-dev-project-my-led1").')
86111
@click.option('--type', type=click.Choice(['LIGHT', 'SWITCH', 'OUTLET']),
87-
required=True)
88-
@click.option('--trait', multiple=True)
89-
@click.option('--manufacturer', required=True)
90-
@click.option('--product-name', required=True)
91-
@click.option('--description')
92-
@click.option('--device', required=True)
93-
@click.option('--nickname')
112+
required=True,
113+
help='Select the type of device hardware that best aligns with '
114+
'your device. Select LIGHT if none of the listed choices aligns '
115+
'with your device.')
116+
@click.option('--trait', multiple=True,
117+
help='Add traits (abilities) that the device supports. Pass '
118+
'this flag multiple times to create a list of traits. Refer to '
119+
'https://developers.google.com/assistant/sdk for a list of '
120+
'supported traits.')
121+
@click.option('--manufacturer', required=True,
122+
help='Enter the manufacturer\'s name in this field (for '
123+
'example, "Assistant SDK developer"). This information may be '
124+
'shown in the Assistant settings and internal analytics.')
125+
@click.option('--product-name', required=True,
126+
help='Enter the product name in this field (for example, '
127+
'"Assistant SDK light").')
128+
@click.option('--description',
129+
help='Enter a description of the product in this field (for '
130+
'example, "Assistant SDK light device").')
131+
@click.option('--device', required=True,
132+
help='Enter an identifier for the device instance. This ID must '
133+
'be unique within all of the devices registered under the same '
134+
'Google Developer project.')
135+
@click.option('--nickname',
136+
help='Enter a nickname for the device. You can use this name '
137+
'when talking to your Assistant to refer to this device.')
94138
@click.pass_context
95139
def register(ctx, model, type, trait, manufacturer, product_name, description,
96140
device, nickname):
141+
"""Registers a device model and instance.
142+
143+
Device model and instance fields can only contain letters, numbers, and the
144+
following symbols: period (.), hyphen (-), underscore (_), space ( ) and
145+
plus (+). The first character of a field must be a letter or number.
146+
"""
97147
ctx.invoke(register_model,
98148
model=model, type=type, trait=trait,
99149
manufacturer=manufacturer,
@@ -103,16 +153,40 @@ def register(ctx, model, type, trait, manufacturer, product_name, description,
103153

104154

105155
@cli.command('register-model')
106-
@click.option('--model', required=True)
156+
@click.option('--model', required=True,
157+
help='Enter a globally-unique identifier for this device model; '
158+
'you should use your project ID as a prefix to help avoid '
159+
'collisions over the range of all projects (for example, '
160+
'"my-dev-project-my-led1").')
107161
@click.option('--type', type=click.Choice(['LIGHT', 'SWITCH', 'OUTLET']),
108-
required=True)
109-
@click.option('--trait', multiple=True)
110-
@click.option('--manufacturer', required=True)
111-
@click.option('--product-name', required=True)
112-
@click.option('--description')
162+
required=True,
163+
help='Select the type of device hardware that best aligns with '
164+
'your device. Select LIGHT if none of the listed choices aligns '
165+
'with your device.')
166+
@click.option('--trait', multiple=True,
167+
help='Add traits (abilities) that the device supports. Pass '
168+
'this flag multiple times to create a list of traits. Refer to '
169+
'https://developers.google.com/assistant/sdk for a list of '
170+
'supported traits.')
171+
@click.option('--manufacturer', required=True,
172+
help='Enter the manufacturer\'s name in this field (for '
173+
'example, "Assistant SDK developer"). This information may be '
174+
'shown in the Assistant settings and internal analytics.')
175+
@click.option('--product-name', required=True,
176+
help='Enter the product name in this field (for example, '
177+
'"Assistant SDK light").')
178+
@click.option('--description',
179+
help='Enter a description of the product in this field (for '
180+
'example, "Assistant SDK light device").')
113181
@click.pass_context
114182
def register_model(ctx, model, type, trait,
115183
manufacturer, product_name, description):
184+
"""Registers a device model.
185+
186+
Device model and instance fields can only contain letters, numbers, and the
187+
following symbols: period (.), hyphen (-), underscore (_), space ( ) and
188+
plus (+). The first character of a field must be a letter or number.
189+
"""
116190
session = ctx.obj['SESSION']
117191

118192
model_base_url = '/'.join([ctx.obj['API_URL'], 'deviceModels'])
@@ -145,11 +219,24 @@ def register_model(ctx, model, type, trait,
145219

146220

147221
@cli.command('register-device')
148-
@click.option('--device', required=True)
149-
@click.option('--model', required=True)
150-
@click.option('--nickname')
222+
@click.option('--device', required=True,
223+
help='Enter an identifier for the device instance. This ID must '
224+
'be unique within all of the devices registered under the same '
225+
'Google Developer project.')
226+
@click.option('--model', required=True,
227+
help='Enter the identifier for an existing device model. This '
228+
'new device instance will be associated with this device model.')
229+
@click.option('--nickname',
230+
help='Enter a nickname for the device. You can use this name '
231+
'when talking to your Assistant to refer to this device.')
151232
@click.pass_context
152233
def register_device(ctx, device, model, nickname):
234+
"""Registers a device instance under an existing device model.
235+
236+
Device model and instance fields can only contain letters, numbers, and the
237+
following symbols: period (.), hyphen (-), underscore (_), space ( ) and
238+
plus (+). The first character of a field must be a letter or number.
239+
"""
153240
session = ctx.obj['SESSION']
154241

155242
device_base_url = '/'.join([ctx.obj['API_URL'], 'devices'])
@@ -177,11 +264,16 @@ def register_device(ctx, device, model, nickname):
177264

178265

179266
@cli.command()
180-
@click.option('--model', 'resource', flag_value='deviceModels', required=True)
181-
@click.option('--device', 'resource', flag_value='devices', required=True)
267+
@click.option('--model', 'resource', flag_value='deviceModels', required=True,
268+
help='Enter the identifier for an existing device model.')
269+
@click.option('--device', 'resource', flag_value='devices', required=True,
270+
help='Enter the identifier for an existing device instance.')
182271
@click.argument('id')
183272
@click.pass_context
184273
def get(ctx, resource, id):
274+
"""Gets all of the information (fields) for a given device model or
275+
instance.
276+
"""
185277
session = ctx.obj['SESSION']
186278
url = '/'.join([ctx.obj['API_URL'], resource, id])
187279
r = session.get(url)
@@ -195,6 +287,10 @@ def get(ctx, resource, id):
195287
@click.option('--device', 'resource', flag_value='devices', required=True)
196288
@click.pass_context
197289
def list(ctx, resource):
290+
"""Lists all of the device models and/or instances associated with the
291+
current Google Developer project. To change the current project, use the
292+
devicetool's --project flag.
293+
"""
198294
session = ctx.obj['SESSION']
199295
url = '/'.join([ctx.obj['API_URL'], resource])
200296
r = session.get(url)

0 commit comments

Comments
 (0)