diff --git a/src/__tests__/commands/apps/delete.test.ts b/src/__tests__/commands/apps/delete.test.ts index c4976797..67eee507 100644 --- a/src/__tests__/commands/apps/delete.test.ts +++ b/src/__tests__/commands/apps/delete.test.ts @@ -5,13 +5,19 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { AppsEndpoint, SmartThingsClient } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/apps/delete.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { chooseApp } from '../../../lib/command/util/apps-util.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const chooseAppMock = jest.fn() jest.unstable_mockModule('../../../lib/command/util/apps-util.js', () => ({ @@ -43,7 +49,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/capabilities.test.ts b/src/__tests__/commands/capabilities.test.ts index 590b6a9d..610f9469 100644 --- a/src/__tests__/commands/capabilities.test.ts +++ b/src/__tests__/commands/capabilities.test.ts @@ -6,6 +6,7 @@ import type { CapabilitiesEndpoint, Capability, OrganizationResponse, SmartThing import type { CommandArgs } from '../../commands/capabilities.js' import type { forAllOrganizations, WithOrganization } from '../../lib/api-helpers.js' +import type { buildEpilog } from '../../lib/help.js' import type { APIOrganizationCommand, APIOrganizationCommandFlags, @@ -40,6 +41,11 @@ jest.unstable_mockModule('../../lib/api-helpers.js', () => ({ forAllOrganizations: forAllOrganizationsMock, })) +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() jest.unstable_mockModule('../../lib/command/api-organization-command.js', () => ({ @@ -116,8 +122,9 @@ test('builder', () => { .toHaveBeenCalledExactlyOnceWith(capabilityIdOrIndexBuilderArgvMock) expect(optionMock).toHaveBeenCalledTimes(2) - expect(epilogMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) describe('handler', () => { diff --git a/src/__tests__/commands/devices/history.test.ts b/src/__tests__/commands/devices/history.test.ts index cea22f70..f2294aa0 100644 --- a/src/__tests__/commands/devices/history.test.ts +++ b/src/__tests__/commands/devices/history.test.ts @@ -5,8 +5,10 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { DevicesEndpoint, HistoryEndpoint, DeviceActivity, Device, PaginatedList } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/devices/history.js' +import type { CLIConfig } from '../../../lib/cli-config.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' -import { calculateOutputFormat, OutputFormatter, writeOutput } from '../../../lib/command/output.js' +import type { calculateOutputFormat, OutputFormatter, writeOutput } from '../../../lib/command/output.js' import type { buildOutputFormatter, buildOutputFormatterBuilder, @@ -22,9 +24,13 @@ import type { import type { historyBuilder } from '../../../lib/command/util/history-builder.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' -import { CLIConfig } from '../../../lib/cli-config.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandBuilderMock, apiCommandMock } = apiCommandMocks('../../..') const calculateOutputFormatMock = jest.fn() @@ -76,6 +82,7 @@ test('builder', () => { yargsMock: buildOutputFormatterBuilderArgvMock, positionalMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -95,6 +102,8 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) describe('handler', () => { diff --git a/src/__tests__/commands/devices/preferences.test.ts b/src/__tests__/commands/devices/preferences.test.ts index 7f91f4ae..5b9ee37a 100644 --- a/src/__tests__/commands/devices/preferences.test.ts +++ b/src/__tests__/commands/devices/preferences.test.ts @@ -4,13 +4,14 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { Device, DevicePreferenceResponse, DevicesEndpoint } from '@smartthings/core-sdk' +import type { CommandArgs } from '../../../commands/devices/preferences.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand } from '../../../lib/command/api-command.js' import type { CustomCommonOutputProducer, formatAndWriteItem, formatAndWriteItemBuilder, } from '../../../lib/command/format.js' -import type { CommandArgs } from '../../../commands/devices/preferences.js' import type { BuildOutputFormatterFlags } from '../.././../lib/command/output-builder.js' import type { SmartThingsCommandFlags } from '../../../lib/command/smartthings-command.js' import type { ChooseFunction } from '../../../lib/command/util/util-util.js' @@ -25,6 +26,11 @@ import { } from '../../test-lib/table-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const chooseDeviceMock = jest.fn>() @@ -49,6 +55,7 @@ test('builder', () => { yargsMock: apiCommandBuilderArgvMock, positionalMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -63,6 +70,8 @@ test('builder', () => { expect(formatAndWriteItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock) expect(positionalMock).toHaveBeenCalledOnce() expect(exampleMock).toHaveBeenCalledOnce() + expect(buildEpilogMock).toHaveBeenCalledOnce() + expect(epilogMock).toHaveBeenCalledOnce() }) const preferences: DevicePreferenceResponse = { diff --git a/src/__tests__/commands/edge/channels/invites.test.ts b/src/__tests__/commands/edge/channels/invites.test.ts index 9a59389e..6be1cb52 100644 --- a/src/__tests__/commands/edge/channels/invites.test.ts +++ b/src/__tests__/commands/edge/channels/invites.test.ts @@ -3,16 +3,22 @@ import { jest } from '@jest/globals' import type { ArgumentsCamelCase, Argv } from 'yargs' import type { CommandArgs } from '../../../../commands/edge/channels/invites.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' -import { outputItemOrList, outputItemOrListBuilder } from '../../../../lib/command/listing-io.js' +import type { edgeCommand, EdgeCommand } from '../../../../lib/command/edge-command.js' +import type { outputItemOrList, outputItemOrListBuilder } from '../../../../lib/command/listing-io.js' import { listTableFieldDefinitions, tableFieldDefinitions } from '../../../../lib/command/util/edge-invites-table.js' +import type { buildListFunction } from '../../../../lib/command/util/edge-invites-util.js' +import type { Invitation, InvitesEndpoint } from '../../../../lib/edge/endpoints/invites.js' import { apiCommandMocks } from '../../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js' -import { Invitation, InvitesEndpoint } from '../../../../lib/edge/endpoints/invites.js' -import type { edgeCommand, EdgeCommand } from '../../../../lib/command/edge-command.js' -import { buildListFunction } from '../../../../lib/command/util/edge-invites-util.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..') const edgeCommandMock = jest.fn() @@ -43,6 +49,7 @@ test('builder', async () => { positionalMock, optionMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -58,6 +65,8 @@ test('builder', async () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) test('handler', async () => { diff --git a/src/__tests__/commands/edge/drivers.test.ts b/src/__tests__/commands/edge/drivers.test.ts index a9e03328..9d2a00a7 100644 --- a/src/__tests__/commands/edge/drivers.test.ts +++ b/src/__tests__/commands/edge/drivers.test.ts @@ -28,12 +28,16 @@ import { type listDrivers, listTableFieldDefinitions, } from '../../../lib/command/util/edge-drivers.js' -import { apiCommandMocks } from '../../test-lib/api-command-mock.js' +import type { buildEpilog } from '../../../lib/help.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' import { tableGeneratorMock } from '../../test-lib/table-mock.js' -const { apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ buildEpilog: buildEpilogMock })) + + +// buildEpilog is mocked; api-command mocks not required for this test post-migration const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() @@ -102,7 +106,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(2) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/locations/create.test.ts b/src/__tests__/commands/locations/create.test.ts index d03ddda6..ed8396b9 100644 --- a/src/__tests__/commands/locations/create.test.ts +++ b/src/__tests__/commands/locations/create.test.ts @@ -4,15 +4,21 @@ import { ArgumentsCamelCase, Argv } from 'yargs' import { Location, LocationCreate, LocationsEndpoint, SmartThingsClient } from '@smartthings/core-sdk' +import type { CommandArgs } from '../../../commands/locations/create.js' +import type { buildEpilog } from '../../../lib/help.js' import { tableFieldDefinitions } from '../../../lib/command/util/locations-util.js' -import { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' -import { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../lib/command/input-and-output-item.js' -import { CommandArgs } from '../../../commands/locations/create.js' +import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' +import type { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../lib/command/input-and-output-item.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const inputAndOutputItemMock = jest.fn() const inputAndOutputItemBuilderMock = jest.fn() @@ -46,7 +52,7 @@ test('builder', () => { expect(inputAndOutputItemBuilderMock).toHaveBeenCalledWith(apiCommandBuilderArgvMock) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/locations/delete.test.ts b/src/__tests__/commands/locations/delete.test.ts index 7c721bfc..85bc1344 100644 --- a/src/__tests__/commands/locations/delete.test.ts +++ b/src/__tests__/commands/locations/delete.test.ts @@ -5,13 +5,19 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { LocationsEndpoint, SmartThingsClient } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/locations/delete.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { chooseLocation } from '../../../lib/command/util/locations-util.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const chooseLocationMock = jest.fn() jest.unstable_mockModule('../../../lib/command/util/locations-util.js', () => ({ @@ -43,7 +49,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/locations/history.test.ts b/src/__tests__/commands/locations/history.test.ts index 6760454b..8c0618f5 100644 --- a/src/__tests__/commands/locations/history.test.ts +++ b/src/__tests__/commands/locations/history.test.ts @@ -6,6 +6,7 @@ import type { DeviceActivity, HistoryEndpoint, PaginatedList } from '@smartthing import type { CommandArgs } from '../../../commands/devices/history.js' import type { CLIConfig } from '../../../lib/cli-config.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import { calculateOutputFormat, OutputFormatter, writeOutput } from '../../../lib/command/output.js' import type { @@ -25,6 +26,11 @@ import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandBuilderMock, apiCommandMock } = apiCommandMocks('../../..') const calculateOutputFormatMock = jest.fn() @@ -76,6 +82,7 @@ test('builder', () => { yargsMock: buildOutputFormatterBuilderArgvMock, positionalMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -95,6 +102,8 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) describe('handler', () => { diff --git a/src/__tests__/commands/locations/rooms.test.ts b/src/__tests__/commands/locations/rooms.test.ts index 398fe3f1..cde1ce73 100644 --- a/src/__tests__/commands/locations/rooms.test.ts +++ b/src/__tests__/commands/locations/rooms.test.ts @@ -5,9 +5,10 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { Room, RoomsEndpoint } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/locations/rooms.js' +import type { WithNamedLocation } from '../../../lib/api-helpers.js' +import type { buildEpilog } from '../../../lib/help.js' import { fatalError } from '../../../lib/util.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' -import type { WithNamedLocation } from '../../../lib/api-helpers.js' import type { outputItemOrList, outputItemOrListBuilder } from '../../../lib/command/listing-io.js' import { tableFieldDefinitions, tableFieldDefinitionsWithLocationName } from '../../../lib/command/util/rooms-table.js' import type { getRoomsWithLocation } from '../../../lib/command/util/rooms-util.js' @@ -15,12 +16,17 @@ import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const fatalErrorMock = jest.fn() jest.unstable_mockModule('../../../lib/util.js', () => ({ fatalError: fatalErrorMock, })) -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const outputItemOrListMock = jest.fn>() const outputItemOrListBuilderMock = jest.fn() @@ -61,7 +67,7 @@ test('builder', async () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(2) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/locations/rooms/create.test.ts b/src/__tests__/commands/locations/rooms/create.test.ts index 64fe68fa..6d5a24d0 100644 --- a/src/__tests__/commands/locations/rooms/create.test.ts +++ b/src/__tests__/commands/locations/rooms/create.test.ts @@ -5,6 +5,7 @@ import { ArgumentsCamelCase, Argv } from 'yargs' import type { Room, RoomRequest, RoomsEndpoint } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/locations/rooms/create.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { inputAndOutputItem, @@ -16,10 +17,14 @@ import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock import { apiCommandMocks } from '../../../test-lib/api-command-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandMock, apiCommandBuilderMock, - apiDocsURLMock, } = apiCommandMocks('../../../..') const inputAndOutputItemMock = @@ -62,7 +67,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(0) expect(optionMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/locations/update.test.ts b/src/__tests__/commands/locations/update.test.ts index 60e31a64..51671ed5 100644 --- a/src/__tests__/commands/locations/update.test.ts +++ b/src/__tests__/commands/locations/update.test.ts @@ -4,10 +4,11 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { Location, LocationUpdate, LocationsEndpoint, SmartThingsClient } from '@smartthings/core-sdk' +import type { CommandArgs } from '../../../commands/locations/update.js' +import type { buildEpilog } from '../../../lib/help.js' import { type chooseLocation, tableFieldDefinitions } from '../../../lib/command/util/locations-util.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../lib/command/input-and-output-item.js' -import type { CommandArgs } from '../../../commands/locations/update.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' @@ -18,7 +19,12 @@ jest.unstable_mockModule('../../../lib/command/util/locations-util.js', () => ({ tableFieldDefinitions, })) -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const inputAndOutputItemMock = jest.fn() const inputAndOutputItemBuilderMock = jest.fn() @@ -54,7 +60,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/logout.test.ts b/src/__tests__/commands/logout.test.ts index 410cc4bc..6ccfde83 100644 --- a/src/__tests__/commands/logout.test.ts +++ b/src/__tests__/commands/logout.test.ts @@ -4,13 +4,19 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { Authenticator } from '@smartthings/core-sdk' -import type { APICommand, APICommandFlags } from '../../lib/command/api-command.js' import type { CommandArgs } from '../../commands/locations.js' +import type { buildEpilog } from '../../lib/help.js' import type { fatalError } from '../../lib/util.js' +import type { APICommand, APICommandFlags } from '../../lib/command/api-command.js' import { apiCommandMocks } from '../test-lib/api-command-mock.js' import { buildArgvMock } from '../test-lib/builder-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..') const fatalErrorMock = jest.fn() @@ -28,6 +34,7 @@ test('builder', () => { const { yargsMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -39,6 +46,8 @@ test('builder', () => { expect(apiCommandBuilderMock).toHaveBeenCalledExactlyOnceWith(yargsMock) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) describe('handler', () => { diff --git a/src/__tests__/commands/schema/regenerate.test.ts b/src/__tests__/commands/schema/regenerate.test.ts index 21760c90..7a24a450 100644 --- a/src/__tests__/commands/schema/regenerate.test.ts +++ b/src/__tests__/commands/schema/regenerate.test.ts @@ -13,11 +13,12 @@ import type { } from '../../../lib/command/api-organization-command.js' import type { outputItem, outputItemBuilder } from '../../../lib/command/output-item.js' import type { chooseSchemaApp } from '../../../lib/command/util/schema-util.js' -import { apiCommandMocks } from '../../test-lib/api-command-mock.js' +import type { buildEpilog } from '../../../lib/help.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' -const { apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ buildEpilog: buildEpilogMock })) const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() @@ -63,7 +64,7 @@ test('builder', () => { expect(outputItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock) expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/virtualdevices.test.ts b/src/__tests__/commands/virtualdevices.test.ts index d4446ee9..459bf578 100644 --- a/src/__tests__/commands/virtualdevices.test.ts +++ b/src/__tests__/commands/virtualdevices.test.ts @@ -9,11 +9,12 @@ import { type SmartThingsClient, } from '@smartthings/core-sdk' +import type { CommandArgs } from '../../commands/virtualdevices.js' import type { withLocationsAndRooms, WithNamedRoom } from '../../lib/api-helpers.js' +import type { buildEpilog } from '../../lib/help.js' import type { APICommand, APICommandFlags } from '../../lib/command/api-command.js' import type { CustomCommonOutputProducer } from '../../lib/command/format.js' import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js' -import type { CommandArgs } from '../../commands/virtualdevices.js' import type { BuildOutputFormatterFlags } from '../../lib/command/output-builder.js' import type { SmartThingsCommandFlags } from '../../lib/command/smartthings-command.js' import { buildTableOutput } from '../../lib/command/util/devices-table.js' @@ -22,6 +23,11 @@ import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js' import { tableGeneratorMock } from '../test-lib/table-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..') const outputItemOrListMock = jest.fn>() @@ -52,6 +58,7 @@ test('builder', () => { optionMock, positionalMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -67,6 +74,8 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(3) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) describe('handler', () => { diff --git a/src/__tests__/commands/virtualdevices/delete.test.ts b/src/__tests__/commands/virtualdevices/delete.test.ts index 1f2bf4be..5689a977 100644 --- a/src/__tests__/commands/virtualdevices/delete.test.ts +++ b/src/__tests__/commands/virtualdevices/delete.test.ts @@ -5,13 +5,19 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import { type Device, DeviceIntegrationType, type DevicesEndpoint } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/virtualdevices/delete.js' -import { chooseDeviceFn } from '../../../lib/command/util/devices-choose.js' +import type { buildEpilog } from '../../../lib/help.js' +import type { APICommand } from '../../../lib/command/api-command.js' +import type { chooseDeviceFn } from '../../../lib/command/util/devices-choose.js' +import type { ChooseFunction } from '../../../lib/command/util/util-util.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock } from '../../test-lib/builder-mock.js' -import { ChooseFunction } from '../../../lib/command/util/util-util.js' -import { APICommand } from '../../../lib/command/api-command.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const chooseDeviceMock = jest.fn>() @@ -31,6 +37,7 @@ test('builder', () => { yargsMock, positionalMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -44,6 +51,8 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) test('handler', async () => { diff --git a/src/__tests__/commands/virtualdevices/events.test.ts b/src/__tests__/commands/virtualdevices/events.test.ts index 77e4f5cb..7e0305fd 100644 --- a/src/__tests__/commands/virtualdevices/events.test.ts +++ b/src/__tests__/commands/virtualdevices/events.test.ts @@ -10,6 +10,7 @@ import { } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/virtualdevices/events.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { CustomCommonOutputProducer } from '../../../lib/command/format.js' import type { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../lib/command/input-and-output-item.js' @@ -23,6 +24,11 @@ import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js import { tableGeneratorMock } from '../../test-lib/table-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const inputAndOutputItemMock = jest.fn>() @@ -83,6 +89,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(4) expect(optionMock).toHaveBeenCalledTimes(0) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/commands/apps/delete.ts b/src/commands/apps/delete.ts index 066bbf76..82f75da8 100644 --- a/src/commands/apps/delete.ts +++ b/src/commands/apps/delete.ts @@ -1,10 +1,10 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../lib/help.js' import { type APICommandFlags, apiCommand, apiCommandBuilder, - apiDocsURL, } from '../../lib/command/api-command.js' import { chooseApp } from '../../lib/command/util/apps-util.js' @@ -27,7 +27,7 @@ const builder = (yargs: Argv): Argv => 'delete the app with the specified id', ], ]) - .epilog(apiDocsURL('deleteApp')) + .epilog(buildEpilog({ command, apiDocs: 'deleteApp' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/capabilities.ts b/src/commands/capabilities.ts index c4619463..c6f8bc2b 100644 --- a/src/commands/capabilities.ts +++ b/src/commands/capabilities.ts @@ -3,7 +3,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Capability } from '@smartthings/core-sdk' import { forAllOrganizations, type WithOrganization } from '../lib/api-helpers.js' -import { apiDocsURL } from '../lib/command/api-command.js' +import { buildEpilog } from '../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -80,7 +80,7 @@ export const builder = (yargs: Argv): Argv => ], ['$0 capabilities --standard', 'list standard capabilities'], ]) - .epilog(apiDocsURL('listNamespacedCapabilities', 'listCapabilities', 'getCapability')) + .epilog(buildEpilog({ command, apiDocs: ['listNamespacedCapabilities', 'listCapabilities', 'getCapability'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/create.ts b/src/commands/deviceprofiles/create.ts index a5ad2cee..dada9020 100644 --- a/src/commands/deviceprofiles/create.ts +++ b/src/commands/deviceprofiles/create.ts @@ -2,7 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DeviceProfile } from '@smartthings/core-sdk' -import { apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -40,10 +40,13 @@ const builder = (yargs: Argv): Argv => ['$0 deviceprofiles:create --dry-run', 'build JSON for a device profile from prompted input'], ['$0 deviceprofiles:create -i my-profile.yaml', 'create a device profile defined in "my-profile.yaml'], ]) - .epilog('Creates a new device profile. If a vid field is not present in the metadata ' + - 'then a default device presentation will be created for this profile and the ' + - 'vid set to reference it.\n\n' + - apiDocsURL('createDeviceProfile')) + .epilog(buildEpilog({ + command, + apiDocs: 'createDeviceProfile', + notes: 'Creates a new device profile. If a vid field is not present in the metadata' + + ' then a default device presentation will be created for this profile and the' + + ' vid set to reference it.', + })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/delete.ts b/src/commands/deviceprofiles/delete.ts index bc4930b4..78d0bdeb 100644 --- a/src/commands/deviceprofiles/delete.ts +++ b/src/commands/deviceprofiles/delete.ts @@ -1,6 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -29,7 +29,7 @@ const builder = (yargs: Argv): Argv => 'delete the device profile with the specified id', ], ]) - .epilog(apiDocsURL('deleteDeviceProfile')) + .epilog(buildEpilog({ command, apiDocs: 'deleteDeviceProfile' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/device-config.ts b/src/commands/deviceprofiles/device-config.ts index d721dc42..74e5a8a4 100644 --- a/src/commands/deviceprofiles/device-config.ts +++ b/src/commands/deviceprofiles/device-config.ts @@ -1,7 +1,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../lib/help.js' import { fatalError } from '../../lib/util.js' -import { apiDocsURL } from '../../lib/command/api-command.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -45,7 +45,7 @@ export const builder = (yargs: Argv): Argv => 'display device config for the specified device profile', ], ]) - .epilog(apiDocsURL('getDeviceProfile', 'getDeviceConfiguration')) + .epilog(buildEpilog({ command, apiDocs: ['getDeviceProfile', 'getDeviceConfiguration'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/presentation.ts b/src/commands/deviceprofiles/presentation.ts index 1aaa7c2c..77f471f0 100644 --- a/src/commands/deviceprofiles/presentation.ts +++ b/src/commands/deviceprofiles/presentation.ts @@ -1,6 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { fatalError } from '../../lib/util.js' import { apiOrganizationCommand, @@ -49,11 +49,14 @@ export const builder = (yargs: Argv): Argv => 'display presentation information for the specified device profile and language', ], ]) - .epilog('Specifying only the presentationId defaults to the language set for the' + - ' computer\'s operating system. The language can be overridden by specifying an ISO' + - ' language code. If "NONE" is specified for the language' + - 'flag then no language header is specified in the API request\n\n' + - apiDocsURL('getDeviceProfile', 'getDevicePresentation')) + .epilog(buildEpilog({ + command, + apiDocs: ['getDeviceProfile', 'getDevicePresentation'], + notes: 'Specifying only the presentationId defaults to the language set for the' + + ' computer\'s operating system. The language can be overridden by specifying an ISO' + + ' language code. If "NONE" is specified for the language' + + ' flag then no language header is specified in the API request.', + })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/publish.ts b/src/commands/deviceprofiles/publish.ts index 1306b537..4db54bdc 100644 --- a/src/commands/deviceprofiles/publish.ts +++ b/src/commands/deviceprofiles/publish.ts @@ -2,8 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { DeviceProfileStatus } from '@smartthings/core-sdk' -import { apiDocsURL } from '../../lib/command/api-command.js' - +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -42,7 +41,7 @@ export const builder = (yargs: Argv): Argv => 'publish the specified device profile', ], ]) - .epilog(apiDocsURL('getDeviceProfile, getDeviceConfiguration')) + .epilog(buildEpilog({ command, apiDocs: ['getDeviceProfile', 'getDeviceConfiguration'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/translations.ts b/src/commands/deviceprofiles/translations.ts index 6ea507f4..221b1f13 100644 --- a/src/commands/deviceprofiles/translations.ts +++ b/src/commands/deviceprofiles/translations.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DeviceProfileTranslations, type LocaleReference } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { fatalError } from '../../lib/util.js' import { apiOrganizationCommand, @@ -62,6 +63,7 @@ const builder = (yargs: Argv): Argv => 'display translations for the specified device profile id and locale', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/translations/delete.ts b/src/commands/deviceprofiles/translations/delete.ts index 75caddc8..6e1bf35b 100644 --- a/src/commands/deviceprofiles/translations/delete.ts +++ b/src/commands/deviceprofiles/translations/delete.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type LocaleReference } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -40,6 +41,7 @@ const builder = (yargs: Argv): Argv => 'delete the specified locale on the specified device profile', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/translations/upsert.ts b/src/commands/deviceprofiles/translations/upsert.ts index 3969d43b..8a2c0dce 100644 --- a/src/commands/deviceprofiles/translations/upsert.ts +++ b/src/commands/deviceprofiles/translations/upsert.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DeviceProfileTranslations } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -40,6 +41,7 @@ const builder = (yargs: Argv): Argv => 'update the translation specified in fr.json on the specified device profile', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/update.ts b/src/commands/deviceprofiles/update.ts index d190af55..10091565 100644 --- a/src/commands/deviceprofiles/update.ts +++ b/src/commands/deviceprofiles/update.ts @@ -2,8 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DeviceProfile } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { fatalError } from '../../lib/util.js' -import { apiDocsURL } from '../../lib/command/api-command.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -47,7 +47,7 @@ const builder = (yargs: Argv): Argv => 'update the specified device profile using the data in my-profile.json', ], ]) - .epilog(apiDocsURL('updateDeviceProfile')) + .epilog(buildEpilog({ command, apiDocs: 'updateDeviceProfile' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/view.ts b/src/commands/deviceprofiles/view.ts index 88a64167..66b11796 100644 --- a/src/commands/deviceprofiles/view.ts +++ b/src/commands/deviceprofiles/view.ts @@ -1,6 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -45,7 +45,7 @@ export const builder = (yargs: Argv): Argv => 'display configuration info for a device profile by id', ], ]) - .epilog(apiDocsURL('getDeviceProfile, getDeviceConfiguration')) + .epilog(buildEpilog({ command, apiDocs: ['getDeviceProfile', 'getDeviceConfiguration'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles/view/create.ts b/src/commands/deviceprofiles/view/create.ts index d5fcf4f0..1f0a95b4 100644 --- a/src/commands/deviceprofiles/view/create.ts +++ b/src/commands/deviceprofiles/view/create.ts @@ -1,5 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -21,7 +22,6 @@ import { prunePresentation, augmentPresentation, } from '../../../lib/command/util/deviceprofiles-view.js' -import { apiDocsURL } from '../../../lib/command/api-command.js' export type CommandArgs = @@ -40,27 +40,30 @@ const builder = (yargs: Argv): Argv => 'create a device profile and device configuration as defined in view.yaml', ], ]) - .epilog('Creates a new device profile and device configuration. Unlike deviceprofiles:create, ' + - 'this command accepts a consolidated object that can include a device configuration ' + - 'in a property named "view".\n\n' + - 'A simple example, written in YAML:\n\n' + - 'name: Test Switch\n' + - 'components:\n' + - ' - id: main\n' + - ' capabilities:\n' + - ' - id: switch\n' + - 'view:\n' + - ' dashboard:\n' + - ' states:\n' + - ' - capability: switch\n' + - ' actions:\n' + - ' - capability: switch\n' + - ' detailView:\n' + - ' - capability: switch\n' + - ' automation:\n' + - ' conditions:\n' + - ' - capability: switch\n\n' + - apiDocsURL('createDeviceProfile', 'createDeviceConfiguration', 'updateDeviceProfile', 'generateDeviceConfig')) + .epilog(buildEpilog({ + command, + formattedNotes: 'Creates a new device profile and device configuration. Unlike deviceprofiles:create, ' + + 'this command accepts a consolidated object that can include a device configuration ' + + 'in a property named "view".\n\n' + + 'A simple example, written in YAML:\n\n' + + 'name: Test Switch\n' + + 'components:\n' + + ' - id: main\n' + + ' capabilities:\n' + + ' - id: switch\n' + + 'view:\n' + + ' dashboard:\n' + + ' states:\n' + + ' - capability: switch\n' + + ' actions:\n' + + ' - capability: switch\n' + + ' detailView:\n' + + ' - capability: switch\n' + + ' automation:\n' + + ' conditions:\n' + + ' - capability: switch', + apiDocs: ['createDeviceProfile', 'createDeviceConfiguration', 'updateDeviceProfile', 'generateDeviceConfig'], + })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/devices/commands.ts b/src/commands/devices/commands.ts index cadef5f3..f55095ac 100644 --- a/src/commands/devices/commands.ts +++ b/src/commands/devices/commands.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { Command } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { inputItem, inputItemBuilder, type InputItemFlags } from '../../lib/command/input-item.js' import { chooseDevice } from '../../lib/command/util/devices-choose.js' import { commandLineInputProcessor, userInputProcessor } from '../../lib/command/input-processor.js' @@ -40,7 +41,7 @@ const builder = (yargs: Argv): Argv => ' specified device (note: quotes prevent shell parsing errors)', ], ]) - .epilog(apiDocsURL('executeDeviceCommands')) + .epilog(buildEpilog({ command, apiDocs: ['executeDeviceCommands'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/devices/health.ts b/src/commands/devices/health.ts index 02e89e0a..676d097c 100644 --- a/src/commands/devices/health.ts +++ b/src/commands/devices/health.ts @@ -1,5 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../lib/help.js' import { apiCommand, apiCommandBuilder, @@ -38,7 +39,7 @@ const builder = (yargs: Argv): Argv => 'display the health status for the specified device', ], ]) - + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/devices/history.ts b/src/commands/devices/history.ts index 830d88d5..60f8392f 100644 --- a/src/commands/devices/history.ts +++ b/src/commands/devices/history.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DeviceActivity } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' import { calculateOutputFormat, writeOutput } from '../../lib/command/output.js' import { @@ -40,6 +41,7 @@ const builder = (yargs: Argv): Argv => ['$0 devices:history 2', 'display history for device listed second in output of devices command'], ['$0 devices:history 92f9920a-7629-40e3-8fdc-14924413897f', 'display history for device by id'], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/devices/preferences.ts b/src/commands/devices/preferences.ts index 537eff6b..d49f5d25 100644 --- a/src/commands/devices/preferences.ts +++ b/src/commands/devices/preferences.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DevicePreferenceResponse } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { type APICommandFlags, apiCommand, apiCommandBuilder } from '../../lib/command/api-command.js' import { chooseDevice } from '../../lib/command/util/devices-choose.js' import { type FormatAndWriteItemFlags, formatAndWriteItem, formatAndWriteItemBuilder } from '../../lib/command/format.js' @@ -24,6 +25,7 @@ const builder = (yargs: Argv): Argv => ['$0 devices:preferences 2', 'display preferences for device listed second in output of devices command'], ['$0 devices:preferences 92f9920a-7629-40e3-8fdc-14924413897f', 'display preferences for device by id'], ]) + .epilog(buildEpilog({ command })) export const buildTableOutput = (tableGenerator: TableGenerator, data: DevicePreferenceResponse): string => { let output = '' diff --git a/src/commands/devices/presentation.ts b/src/commands/devices/presentation.ts index ba42580c..75d0dab3 100644 --- a/src/commands/devices/presentation.ts +++ b/src/commands/devices/presentation.ts @@ -3,9 +3,9 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { apiCommand, apiCommandBuilder, - apiDocsURL, type APICommandFlags, } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { formatAndWriteItem, formatAndWriteItemBuilder, @@ -40,7 +40,7 @@ const builder = (yargs: Argv): Argv => 'display the presentation for the specified device', ], ]) - .epilog(apiDocsURL('getDevicePresentation')) + .epilog(buildEpilog({ command, apiDocs: ['getDevicePresentation'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { diff --git a/src/commands/devices/rename.ts b/src/commands/devices/rename.ts index 5172b7ed..3aca34c7 100644 --- a/src/commands/devices/rename.ts +++ b/src/commands/devices/rename.ts @@ -1,7 +1,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { stringInput } from '../../lib/user-query.js' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { outputItem, outputItemBuilder, type OutputItemFlags } from '../../lib/command/output-item.js' import { chooseDevice } from '../../lib/command/util/devices-choose.js' import { buildTableOutput } from '../../lib/command/util/devices-table.js' @@ -30,7 +31,7 @@ const builder = (yargs: Argv): Argv => 'rename the specified device with the specified name', ], ]) - .epilog(apiDocsURL('updateDevice')) + .epilog(buildEpilog({ command, apiDocs: ['updateDevice'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/devices/status.ts b/src/commands/devices/status.ts index a8f5214e..37fb68eb 100644 --- a/src/commands/devices/status.ts +++ b/src/commands/devices/status.ts @@ -1,6 +1,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { type APICommandFlags, apiCommand, apiCommandBuilder, apiDocsURL } from '../../lib/command/api-command.js' +import { type APICommandFlags, apiCommand, apiCommandBuilder } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { type FormatAndWriteItemFlags, formatAndWriteItem, formatAndWriteItemBuilder } from '../../lib/command/format.js' import { chooseDevice } from '../../lib/command/util/devices-choose.js' import { buildStatusTableOutput } from '../../lib/command/util/devices-table.js' @@ -25,7 +26,7 @@ const builder = (yargs: Argv): Argv => ['$0 devices:status 3', 'display component attributes for third device listed in output of devices command'], ['$0 devices:status eee23fb0-38cd-4f07-be6d-dec9000b41fe', 'display component attributes for device by id'], ]) - .epilog(apiDocsURL('getDeviceStatus')) + .epilog(buildEpilog({ command, apiDocs: ['getDeviceStatus'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/channels/create.ts b/src/commands/edge/channels/create.ts index 226bd1cf..146eace4 100644 --- a/src/commands/edge/channels/create.ts +++ b/src/commands/edge/channels/create.ts @@ -2,9 +2,10 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Channel, type ChannelCreate } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { stringInput } from '../../../lib/user-query.js' import { urlValidate } from '../../../lib/validate-util.js' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { inputAndOutputItem, inputAndOutputItemBuilder, @@ -37,7 +38,7 @@ const builder = (yargs: Argv): Argv => 'create a channel as defined in channel.json', ], ]) - .epilog(apiDocsURL('createChannel')) + .epilog(buildEpilog({ command, apiDocs: 'createChannel' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/channels/invites.ts b/src/commands/edge/channels/invites.ts index 2b7c0593..b31be305 100644 --- a/src/commands/edge/channels/invites.ts +++ b/src/commands/edge/channels/invites.ts @@ -1,5 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { edgeCommand } from '../../../lib/command/edge-command.js' import { @@ -49,6 +50,7 @@ const builder = (yargs: Argv): Argv => 'list invites for the specified channel', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = edgeCommand(await apiCommand(argv)) diff --git a/src/commands/edge/channels/invites/accept.ts b/src/commands/edge/channels/invites/accept.ts index 784ac176..7039f438 100644 --- a/src/commands/edge/channels/invites/accept.ts +++ b/src/commands/edge/channels/invites/accept.ts @@ -1,5 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../../lib/command/api-command.js' import { edgeCommand } from '../../../../lib/command/edge-command.js' @@ -23,6 +24,7 @@ const builder = (yargs: Argv): Argv => 'accept the specified invite', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = edgeCommand(await apiCommand(argv)) diff --git a/src/commands/edge/channels/invites/delete.ts b/src/commands/edge/channels/invites/delete.ts index 6c669a46..7b71f37e 100644 --- a/src/commands/edge/channels/invites/delete.ts +++ b/src/commands/edge/channels/invites/delete.ts @@ -1,5 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../../lib/command/api-command.js' import { edgeCommand } from '../../../../lib/command/edge-command.js' import { chooseChannel } from '../../../../lib/command/util/edge/channels-choose.js' @@ -37,6 +38,7 @@ const builder = (yargs: Argv): Argv => 'delete the specified invite', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = edgeCommand(await apiCommand(argv)) diff --git a/src/commands/edge/channels/update.ts b/src/commands/edge/channels/update.ts index 03509e87..e8eb4d6e 100644 --- a/src/commands/edge/channels/update.ts +++ b/src/commands/edge/channels/update.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Channel, type ChannelUpdate } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { inputAndOutputItem, inputAndOutputItemBuilder, @@ -36,7 +37,7 @@ const builder = (yargs: Argv): Argv => 'update the specified channel using the data in channel.json', ], ]) - .epilog(apiDocsURL('updateChannel')) + .epilog(buildEpilog({ command, apiDocs: 'updateChannel' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers.ts b/src/commands/edge/drivers.ts index 2cfd1b37..2f57fc42 100644 --- a/src/commands/edge/drivers.ts +++ b/src/commands/edge/drivers.ts @@ -23,7 +23,7 @@ import { listDrivers, listTableFieldDefinitions, } from '../../lib/command/util/edge-drivers.js' -import { apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' export type CommandArgs = APIOrganizationCommandFlags & AllOrganizationFlags & OutputItemOrListFlags & { @@ -54,13 +54,11 @@ const builder = (yargs: Argv): Argv => 'get information on a specific version of a driver', ], ]) - .epilog( - 'Use this command to list all drivers you own, even if they are not yet assigned to' + - ' a channel.\n\n' + - 'See also drivers:installed to list installed drivers and channels:drivers to list' + - ' drivers that are part of a channel you own or have subscribed to.\n\n' + - apiDocsURL('listDrivers', 'getDriver', 'getDriverRevision'), - ) + .epilog(buildEpilog({ + command, + apiDocs: ['listDrivers', 'getDriver', 'getDriverRevision'], + formattedNotes: 'Use this command to list all drivers you own, even if they are not yet assigned to a channel.\n\nSee also drivers:installed to list installed drivers and channels:drivers to list drivers that are part of a channel you own or have subscribed to.', + })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/locations/create.ts b/src/commands/locations/create.ts index a8bf7738..5322fe8d 100644 --- a/src/commands/locations/create.ts +++ b/src/commands/locations/create.ts @@ -2,12 +2,12 @@ import { ArgumentsCamelCase, Argv, CommandModule } from 'yargs' import { LocationCreate } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { tableFieldDefinitions } from '../../lib/command/util/locations-util.js' import { type APICommandFlags, apiCommand, apiCommandBuilder, - apiDocsURL, } from '../../lib/command/api-command.js' import { type InputAndOutputItemFlags, @@ -30,7 +30,7 @@ const builder = (yargs: Argv): Argv => 'create a location defined in "my-location.yaml"', ], ]) - .epilog(apiDocsURL('createLocation')) + .epilog(buildEpilog({ command, apiDocs: 'createLocation' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/delete.ts b/src/commands/locations/delete.ts index 5554e4df..981e5537 100644 --- a/src/commands/locations/delete.ts +++ b/src/commands/locations/delete.ts @@ -1,10 +1,10 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../lib/help.js' import { type APICommandFlags, apiCommand, apiCommandBuilder, - apiDocsURL, } from '../../lib/command/api-command.js' import { chooseLocation } from '../../lib/command/util/locations-util.js' @@ -27,7 +27,7 @@ const builder = (yargs: Argv): Argv => 'delete the location with the specified id', ], ]) - .epilog(apiDocsURL('deleteLocation')) + .epilog(buildEpilog({ command, apiDocs: 'deleteLocation' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/history.ts b/src/commands/locations/history.ts index fc510765..ba12edd1 100644 --- a/src/commands/locations/history.ts +++ b/src/commands/locations/history.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DeviceActivity } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' import { calculateOutputFormat, writeOutput } from '../../lib/command/output.js' import { @@ -40,6 +41,7 @@ const builder = (yargs: Argv): Argv => ['$0 locations:history 2', 'display history for location listed second in output of locations command'], ['$0 locations:history 92f9920a-7629-40e3-8fdc-14924413897f', 'display history for location by id'], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/modes.ts b/src/commands/locations/modes.ts index 15776a7d..857b5b52 100644 --- a/src/commands/locations/modes.ts +++ b/src/commands/locations/modes.ts @@ -3,8 +3,9 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Mode } from '@smartthings/core-sdk' import { type WithNamedLocation } from '../../lib/api-helpers.js' +import { buildEpilog } from '../../lib/help.js' import { fatalError } from '../../lib/util.js' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' import { outputItemOrList, outputItemOrListBuilder, @@ -48,7 +49,7 @@ const builder = (yargs: Argv): Argv => ['$0 locations:modes --verbose', 'include location info in the output'], ['$0 locations:modes --location=5dfd6626-ab1d-42da-bb76-90def3153998', 'list all modes in a particular location'], ]) - .epilog(apiDocsURL('getModes', 'getMode')) + .epilog(buildEpilog({ command, apiDocs: ['getModes', 'getMode'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/modes/create.ts b/src/commands/locations/modes/create.ts index 5e1e4e66..866e59bd 100644 --- a/src/commands/locations/modes/create.ts +++ b/src/commands/locations/modes/create.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Mode, type ModeRequest } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { CommonOutputProducer } from '../../../lib/command/format.js' import { inputAndOutputItem, @@ -37,7 +38,7 @@ const builder = (yargs: Argv): Argv => 'create a new mode in the specified location as defined in new-mode.json', ], ]) - .epilog(apiDocsURL('createMode')) + .epilog(buildEpilog({ command, apiDocs: 'createMode' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/modes/delete.ts b/src/commands/locations/modes/delete.ts index e3af0ddf..f339c1f2 100644 --- a/src/commands/locations/modes/delete.ts +++ b/src/commands/locations/modes/delete.ts @@ -1,6 +1,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { apiCommand, apiCommandBuilder, apiDocsURL, type APICommandFlags } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { chooseMode } from '../../../lib/command/util/modes-choose.js' @@ -30,7 +31,7 @@ const builder = (yargs: Argv): Argv => 'delete the mode with the specified id', ], ]) - .epilog(apiDocsURL('deleteMode')) + .epilog(buildEpilog({ command, apiDocs: 'deleteMode' })) const handler = async (argv: ArgumentsCamelCase): Promise => { diff --git a/src/commands/locations/modes/getcurrent.ts b/src/commands/locations/modes/getcurrent.ts index cd758117..8f38639c 100644 --- a/src/commands/locations/modes/getcurrent.ts +++ b/src/commands/locations/modes/getcurrent.ts @@ -3,7 +3,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Mode } from '@smartthings/core-sdk' import { withLocation, type WithNamedLocation } from '../../../lib/api-helpers.js' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { formatAndWriteItem, formatAndWriteItemBuilder, @@ -47,7 +48,7 @@ const builder = (yargs: Argv): Argv => 'get the current mode for a specified location', ], ]) - .epilog(apiDocsURL('getCurrentMode')) + .epilog(buildEpilog({ command, apiDocs: 'getCurrentMode' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/modes/setcurrent.ts b/src/commands/locations/modes/setcurrent.ts index 7c85807a..75fbea2f 100644 --- a/src/commands/locations/modes/setcurrent.ts +++ b/src/commands/locations/modes/setcurrent.ts @@ -1,6 +1,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { apiCommand, apiCommandBuilder, apiDocsURL, type APICommandFlags } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { chooseMode } from '../../../lib/command/util/modes-choose.js' @@ -33,7 +34,7 @@ const builder = (yargs: Argv): Argv => 'set the specified mode to be current for its location', ], ]) - .epilog(apiDocsURL('changeMode')) + .epilog(buildEpilog({ command, apiDocs: 'changeMode' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/modes/update.ts b/src/commands/locations/modes/update.ts index 7ec722c0..694157d0 100644 --- a/src/commands/locations/modes/update.ts +++ b/src/commands/locations/modes/update.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Mode, type ModeRequest } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { CommonOutputProducer } from '../../../lib/command/format.js' import { inputAndOutputItem, @@ -43,7 +44,7 @@ const builder = (yargs: Argv): Argv => 'update a specified mode using the data in mode.json', ], ]) - .epilog(apiDocsURL('updateMode')) + .epilog(buildEpilog({ command, apiDocs: 'updateMode' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/rooms.ts b/src/commands/locations/rooms.ts index 68c78453..32e7ec0a 100644 --- a/src/commands/locations/rooms.ts +++ b/src/commands/locations/rooms.ts @@ -3,8 +3,9 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Room } from '@smartthings/core-sdk' import { type WithNamedLocation } from '../../lib/api-helpers.js' +import { buildEpilog } from '../../lib/help.js' import { fatalError } from '../../lib/util.js' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' import { outputItemOrList, outputItemOrListBuilder, @@ -46,7 +47,7 @@ const builder = (yargs: Argv): Argv => ], ['$0 locations:rooms 5dfd6626-ab1d-42da-bb76-90def3153998', 'display details for a room by id'], ]) - .epilog(apiDocsURL('listRooms', 'getRoom')) + .epilog(buildEpilog({ command, apiDocs: ['listRooms', 'getRoom'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/rooms/create.ts b/src/commands/locations/rooms/create.ts index 7b4d85c4..9a2bc445 100644 --- a/src/commands/locations/rooms/create.ts +++ b/src/commands/locations/rooms/create.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Room, type RoomRequest } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { inputAndOutputItem, inputAndOutputItemBuilder, @@ -41,7 +42,7 @@ const builder = (yargs: Argv): Argv => 'create a room in the specified location with the data in "room-info.json"', ], ]) - .epilog(apiDocsURL('createRoom')) + .epilog(buildEpilog({ command, apiDocs: 'createRoom' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/locations/update.ts b/src/commands/locations/update.ts index a51b7159..89113d1d 100644 --- a/src/commands/locations/update.ts +++ b/src/commands/locations/update.ts @@ -2,12 +2,12 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Location, type LocationUpdate } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { chooseLocation, tableFieldDefinitions } from '../../lib/command/util/locations-util.js' import { type APICommandFlags, apiCommand, apiCommandBuilder, - apiDocsURL, } from '../../lib/command/api-command.js' import { type InputAndOutputItemFlags, @@ -37,7 +37,7 @@ const builder = (yargs: Argv): Argv => 'update the location with the given id using the data in "my-location.json"', ], ]) - .epilog(apiDocsURL('updateLocation')) + .epilog(buildEpilog({ command, apiDocs: 'updateLocation' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/logout.ts b/src/commands/logout.ts index fca22147..1f8b29fb 100644 --- a/src/commands/logout.ts +++ b/src/commands/logout.ts @@ -1,7 +1,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../lib/command/api-command.js' +import { buildEpilog } from '../lib/help.js' import { fatalError } from '../lib/util.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../lib/command/api-command.js' export type CommandArgs = APICommandFlags @@ -16,6 +17,7 @@ const builder = (yargs: Argv): Argv => ['$0', 'log out of default profile'], ['$0 --profile hub2', 'log out of profile named "hub2"'], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/presentation.ts b/src/commands/presentation.ts index 082a2e20..6ed971dc 100644 --- a/src/commands/presentation.ts +++ b/src/commands/presentation.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type PresentationDevicePresentation } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, apiDocsURL, type APICommandFlags } from '../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../lib/command/api-command.js' +import { buildEpilog } from '../lib/help.js' import { outputItem, outputItemBuilder, type OutputItemFlags } from '../lib/command/output-item.js' import { buildTableOutput } from '../lib/command/util/presentation-table.js' @@ -45,9 +46,13 @@ const builder = (yargs: Argv): Argv => 'display the specified presentation, which is associated with the DoodadsInc manufacturer id', ], ]) - .epilog('The language can be overridden by specifying an ISO language code with the "--language" option. If' + - ' "NONE" is specified for the language code then no language header is specified in the API request.\n\n' + - apiDocsURL('getDevicePresentation')) + .epilog(buildEpilog({ + command, + apiDocs: ['getDevicePresentation'], + notes: + 'The language can be overridden by specifying an ISO language code with the "--language" option. ' + + 'If "NONE" is specified for the language code then no language header is specified in the API request.', + })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/rules.ts b/src/commands/rules.ts index 407d9eb3..86f3f1e7 100644 --- a/src/commands/rules.ts +++ b/src/commands/rules.ts @@ -4,7 +4,7 @@ import { type Rule } from '@smartthings/core-sdk' import { type WithNamedLocation } from '../lib/api-helpers.js' import { buildEpilog } from '../lib/help.js' -import { apiCommand, apiCommandBuilder, APICommandFlags } from '../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../lib/command/api-command.js' import { outputItemOrList, outputItemOrListBuilder, diff --git a/src/commands/schema/regenerate.ts b/src/commands/schema/regenerate.ts index d39ec595..53185f76 100644 --- a/src/commands/schema/regenerate.ts +++ b/src/commands/schema/regenerate.ts @@ -1,6 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -34,8 +34,11 @@ const builder = (yargs: Argv): Argv => 'regenerate the client id and secret for for the specified Schema App link', ], ]) - .epilog('NOTE: The previous values will be invalidated, which may affect existing installations.\n\n' + - apiDocsURL('generateStOauthCredentials')) + .epilog(buildEpilog({ + command, + apiDocs: ['generateStOauthCredentials'], + formattedNotes: 'The previous values will be invalidated, which may affect existing installations.', + })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/virtualdevices.ts b/src/commands/virtualdevices.ts index 5f159d11..7065529f 100644 --- a/src/commands/virtualdevices.ts +++ b/src/commands/virtualdevices.ts @@ -7,7 +7,7 @@ import { } from '@smartthings/core-sdk' import { withLocationsAndRooms, type WithNamedRoom } from '../lib/api-helpers.js' -import { buildTableOutput } from '../lib/command/util/devices-table.js' +import { buildEpilog } from '../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../lib/command/api-command.js' import { outputItemOrList, @@ -15,6 +15,7 @@ import { type OutputItemOrListConfig, type OutputItemOrListFlags, } from '../lib/command/listing-io.js' +import { buildTableOutput } from '../lib/command/util/devices-table.js' export type CommandArgs = APICommandFlags & OutputItemOrListFlags & { @@ -71,6 +72,7 @@ const builder = (yargs: Argv): Argv => 'list all virtual devices in the specified location', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/virtualdevices/create-standard.ts b/src/commands/virtualdevices/create-standard.ts index 6b3bd7f1..433513f0 100644 --- a/src/commands/virtualdevices/create-standard.ts +++ b/src/commands/virtualdevices/create-standard.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Device, type VirtualDeviceStandardCreateRequest } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { fatalError } from '../../lib/util.js' import { apiCommand, type APICommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' import { @@ -69,10 +70,13 @@ const builder = (yargs: Argv): Argv => 'create a virtual device, specifying all details on the command line', ], ]) - .epilog('The command can be run interactively in question & answer mode, with command line parameters,' + - ' or with input from a file or standard in. You can also run this command multiple times with the same input' + - ' file but different command line arguments to create multiple devices with different names in different' + - ' locations and rooms.') + .epilog(buildEpilog({ + command, + notes: 'The command can be run interactively in question & answer mode, with command line parameters,' + + ' or with input from a file or standard in. You can also run this command multiple times with the' + + ' same input file but different command line arguments to create multiple devices with different' + + ' names in different locations and rooms.', + })) const mergeCreateFlagValues = (flags: CommandArgs, data: VirtualDeviceStandardCreateRequest): VirtualDeviceStandardCreateRequest => { if (flags.name) { diff --git a/src/commands/virtualdevices/create.ts b/src/commands/virtualdevices/create.ts index d8ee5ecb..92794364 100644 --- a/src/commands/virtualdevices/create.ts +++ b/src/commands/virtualdevices/create.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Device, type VirtualDeviceCreateRequest } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { fatalError } from '../../lib/util.js' import { type APIOrganizationCommand, @@ -92,10 +93,13 @@ const builder = (yargs: Argv): Argv => 'create a virtual device using command line parameters for all values', ], ]) - .epilog('The command can be run interactively in question & answer mode, with command line parameters,' + - ' or with input from a file or standard in. You can also run this command multiple times with the same' + - ' input file but different command line arguments to create multiple devices with different names in' + - ' different locations and rooms.') + .epilog(buildEpilog({ + command, + notes: 'The command can be run interactively in question & answer mode, with command line parameters,' + + ' or with input from a file or standard in. You can also run this command multiple times with the same' + + ' input file but different command line arguments to create multiple devices with different names in' + + ' different locations and rooms.', + })) const mergeCreateFlagValues = (flags: CommandArgs, data: VirtualDeviceCreateRequest): VirtualDeviceCreateRequest => { if (flags.name) { diff --git a/src/commands/virtualdevices/delete.ts b/src/commands/virtualdevices/delete.ts index 3b017e50..7bfde91c 100644 --- a/src/commands/virtualdevices/delete.ts +++ b/src/commands/virtualdevices/delete.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { DeviceIntegrationType } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { type APICommandFlags, apiCommand, apiCommandBuilder } from '../../lib/command/api-command.js' import { chooseDeviceFn } from '../../lib/command/util/devices-choose.js' @@ -24,6 +25,7 @@ const builder = (yargs: Argv): Argv => 'delete the device with the specified id', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/virtualdevices/events.ts b/src/commands/virtualdevices/events.ts index 6d683d8a..c61d1762 100644 --- a/src/commands/virtualdevices/events.ts +++ b/src/commands/virtualdevices/events.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DeviceEvent, DeviceIntegrationType } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' import { inputAndOutputItem, @@ -50,8 +51,11 @@ const builder = (yargs: Argv): Argv => 'create an event, specifying all details on the command line', ], ]) - .epilog('The command can be run interactively in question & answer mode, with command line parameters,' + - ' or with input from a file or standard in.') + .epilog(buildEpilog({ + command, + notes: 'The command can be run interactively in question & answer mode, with command line parameters,' + + ' or with input from a file or standard in.', + })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv)