Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 204ba89

Browse files
committed
PR comments
1 parent 4c6e351 commit 204ba89

File tree

4 files changed

+96
-102
lines changed

4 files changed

+96
-102
lines changed

packages/luis/README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<!-- commands -->
1313
* [`bf luis:convert`](#bf-luisconvert)
1414
* [`bf luis:generate:cs`](#bf-luisgeneratecs)
15-
* [`bf luis:generate:ts [FILE]`](#bf-luisgeneratets-file)
15+
* [`bf luis:generate:ts`](#bf-luisgeneratets)
1616
* [`bf luis:translate`](#bf-luistranslate)
1717
* [`bf qnamaker:convert`](#bf-qnamakerconvert)
1818
* [`bf qnamaker:translate`](#bf-qnamakertranslate)
@@ -42,12 +42,44 @@ _See code: [src/commands/luis/convert.ts](https://github.com/microsoft/botframew
4242

4343
## `bf luis:generate:cs`
4444

45-
describe the command here
45+
Generate:cs generates a strongly typed C# source code from an exported (json) LUIS model.
4646

4747
```
4848
USAGE
4949
$ bf luis:generate:cs
5050
51+
OPTIONS
52+
--className=className Name of the class
53+
--in=in Source .lu file(s) or LUIS application JSON model
54+
--out=out Output file or folder name. If not specified stdout will be used as output
55+
```
56+
57+
_See code: [src/commands/luis/generate/cs.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/generate/cs.ts)_
58+
59+
## `bf luis:generate:ts`
60+
61+
Generate:ts generates a strongly typed typescript source code from an exported (json) LUIS model.
62+
63+
```
64+
USAGE
65+
$ bf luis:generate:ts
66+
67+
OPTIONS
68+
--className=className Name of the class
69+
--in=in Source .lu file(s) or LUIS application JSON model
70+
--out=out Output file or folder name. If not specified stdout will be used as output
71+
```
72+
73+
_See code: [src/commands/luis/generate/ts.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/generate/ts.ts)_
74+
75+
## `bf luis:translate`
76+
77+
Translate given LUIS application JSON model or lu file(s)
78+
79+
```
80+
USAGE
81+
$ bf luis:translate
82+
5183
OPTIONS
5284
--in=in (required) Source .lu file(s) or LUIS application JSON model
5385
--out=out Output folder name. If not specified stdout will be used as output
@@ -59,7 +91,7 @@ OPTIONS
5991
--translatekey=translatekey (required) Machine translation endpoint key.
6092
```
6193

62-
_See code: [src/commands/luis/generate/cs.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/generate/cs.ts)_
94+
_See code: [src/commands/luis/translate.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/translate.ts)_
6395

6496
## `bf qnamaker:convert`
6597

@@ -79,7 +111,7 @@ OPTIONS
79111
--sort When set, questions collections are alphabetically sorted are alphabetically sorted in .lu files
80112
```
81113

82-
_See code: [src/commands/luis/generate/ts.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/generate/ts.ts)_
114+
_See code: [src/commands/qnamaker/convert.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/qnamaker/convert.ts)_
83115

84116
## `bf qnamaker:translate`
85117

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import {CLIError, Command, flags} from '@microsoft/bf-cli-command'
2-
import {camelCase, upperFirst} from 'lodash'
1+
import { CLIError, Command, flags } from '@microsoft/bf-cli-command'
2+
import { camelCase, upperFirst } from 'lodash'
33
import * as path from 'path'
44

5-
import {LuisToCsConverter} from '../../../parser/converters/luis-to-cs-converter'
6-
import {Utils} from '../../../utils'
5+
import { LuisToCsConverter } from '../../../parser/converters/luis-to-cs-converter'
6+
import { Utils } from '../../../utils'
77

88
const fs = require('fs-extra')
99

1010
export default class LuisGenerateCs extends Command {
1111
static description = 'Generate:cs generates a strongly typed C# source code from an exported (json) LUIS model.'
1212

1313
static flags: flags.Input<any> = {
14-
in: flags.string({description: 'Source .lu file(s) or LUIS application JSON model'}),
15-
out: flags.string({description: 'Output file or folder name. If not specified stdout will be used as output', default: ''}),
16-
className: flags.string({description: 'Name of the class'}),
14+
in: flags.string({ description: 'Source .lu file(s) or LUIS application JSON model' }),
15+
out: flags.string({ description: 'Output file or folder name. If not specified stdout will be used as output', default: '' }),
16+
className: flags.string({ description: 'Name of the class' }),
1717
}
1818

1919
reorderEntities(app: any, name: string): void {
@@ -23,39 +23,35 @@ export default class LuisGenerateCs extends Command {
2323
}
2424

2525
async run() {
26-
try {
27-
const {flags} = this.parse(LuisGenerateCs)
28-
let space = 'Luis'
29-
let stdInput = await this.readStdin()
30-
31-
const pathPrefix = path.isAbsolute(flags.in) ? '' : process.cwd()
32-
const app = stdInput ? JSON.parse(stdInput as string) : await fs.readJSON(path.join(pathPrefix, flags.in))
33-
34-
flags.className = flags.className || app.name
35-
flags.className = upperFirst(camelCase(flags.className))
36-
37-
const dot_index = flags.className ? flags.className.indexOf('.') : -1
38-
if (dot_index !== -1) {
39-
space = flags.className.substr(dot_index + 1)
40-
flags.className = flags.className.substr(0, dot_index)
41-
}
42-
43-
this.reorderEntities(app, 'entities')
44-
this.reorderEntities(app, 'prebuiltEntities')
45-
this.reorderEntities(app, 'closedLists')
46-
this.reorderEntities(app, 'regex_entities')
47-
this.reorderEntities(app, 'patternAnyEntities')
48-
this.reorderEntities(app, 'composites')
49-
50-
const outputPath = Utils.validatePath(flags.out, process.cwd(), flags.className + '.cs')
51-
52-
this.log(
53-
`Generating file at ${outputPath || ''} that contains class ${space}.${flags.className}.`
54-
)
55-
56-
await LuisToCsConverter.writeFromLuisJson(app, flags.className, space, outputPath)
57-
} catch (err) {
58-
throw new CLIError(err)
26+
const { flags } = this.parse(LuisGenerateCs)
27+
let space = 'Luis'
28+
let stdInput = await this.readStdin()
29+
30+
const pathPrefix = path.isAbsolute(flags.in) ? '' : process.cwd()
31+
const app = stdInput ? JSON.parse(stdInput as string) : await fs.readJSON(path.join(pathPrefix, flags.in))
32+
33+
flags.className = flags.className || app.name
34+
flags.className = upperFirst(camelCase(flags.className))
35+
36+
const dot_index = flags.className ? flags.className.indexOf('.') : -1
37+
if (dot_index !== -1) {
38+
space = flags.className.substr(dot_index + 1)
39+
flags.className = flags.className.substr(0, dot_index)
5940
}
41+
42+
this.reorderEntities(app, 'entities')
43+
this.reorderEntities(app, 'prebuiltEntities')
44+
this.reorderEntities(app, 'closedLists')
45+
this.reorderEntities(app, 'regex_entities')
46+
this.reorderEntities(app, 'patternAnyEntities')
47+
this.reorderEntities(app, 'composites')
48+
49+
const outputPath = Utils.validatePath(flags.out, process.cwd(), flags.className + '.cs')
50+
51+
this.log(
52+
`Generating file at ${outputPath || ''} that contains class ${space}.${flags.className}.`
53+
)
54+
55+
await LuisToCsConverter.writeFromLuisJson(app, flags.className, space, outputPath)
6056
}
6157
}
Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import {CLIError, Command, flags} from '@microsoft/bf-cli-command'
2-
import {camelCase, kebabCase, upperFirst} from 'lodash'
1+
import { CLIError, Command, flags } from '@microsoft/bf-cli-command'
2+
import { camelCase, kebabCase, upperFirst } from 'lodash'
33
import * as path from 'path'
44

5-
import {LuisToTsConverter} from '../../../parser/converters/luis-to-ts-converter'
6-
import {Utils} from '../../../utils'
5+
import { LuisToTsConverter } from '../../../parser/converters/luis-to-ts-converter'
6+
import { Utils } from '../../../utils'
77

88
const fs = require('fs-extra')
99

1010
export default class LuisGenerateTs extends Command {
1111
static description = 'Generate:ts generates a strongly typed typescript source code from an exported (json) LUIS model.'
1212

1313
static flags: flags.Input<any> = {
14-
in: flags.string({description: 'Source .lu file(s) or LUIS application JSON model'}),
15-
out: flags.string({description: 'Output file or folder name. If not specified stdout will be used as output', default: ''}),
16-
className: flags.string({description: 'Name of the class'}),
14+
in: flags.string({ description: 'Source .lu file(s) or LUIS application JSON model' }),
15+
out: flags.string({ description: 'Output file or folder name. If not specified stdout will be used as output', default: '' }),
16+
className: flags.string({ description: 'Name of the class' }),
1717
}
1818

1919
reorderEntities(app: any, name: string): void {
@@ -23,32 +23,28 @@ export default class LuisGenerateTs extends Command {
2323
}
2424

2525
async run() {
26-
try {
27-
const {flags} = this.parse(LuisGenerateTs)
28-
let stdInput = await this.readStdin()
26+
const { flags } = this.parse(LuisGenerateTs)
27+
let stdInput = await this.readStdin()
2928

30-
const pathPrefix = path.isAbsolute(flags.in) ? '' : process.cwd()
31-
const app = stdInput ? JSON.parse(stdInput as string) : await fs.readJSON(path.join(pathPrefix, flags.in))
29+
const pathPrefix = path.isAbsolute(flags.in) ? '' : process.cwd()
30+
const app = stdInput ? JSON.parse(stdInput as string) : await fs.readJSON(path.join(pathPrefix, flags.in))
3231

33-
flags.className = flags.className || app.name
34-
flags.className = upperFirst(camelCase(flags.className))
32+
flags.className = flags.className || app.name
33+
flags.className = upperFirst(camelCase(flags.className))
3534

36-
this.reorderEntities(app, 'entities')
37-
this.reorderEntities(app, 'prebuiltEntities')
38-
this.reorderEntities(app, 'closedLists')
39-
this.reorderEntities(app, 'regex_entities')
40-
this.reorderEntities(app, 'patternAnyEntities')
41-
this.reorderEntities(app, 'composites')
35+
this.reorderEntities(app, 'entities')
36+
this.reorderEntities(app, 'prebuiltEntities')
37+
this.reorderEntities(app, 'closedLists')
38+
this.reorderEntities(app, 'regex_entities')
39+
this.reorderEntities(app, 'patternAnyEntities')
40+
this.reorderEntities(app, 'composites')
4241

43-
const outputPath = Utils.validatePath(flags.out, process.cwd(), kebabCase(flags.className) + '.ts')
42+
const outputPath = Utils.validatePath(flags.out, process.cwd(), kebabCase(flags.className) + '.ts')
4443

45-
this.log(
46-
`Generating file at ${outputPath || ''} that contains class ${flags.className}.`
47-
)
44+
this.log(
45+
`Generating file at ${outputPath || ''} that contains class ${flags.className}.`
46+
)
4847

49-
await LuisToTsConverter.writeFromLuisJson(app, flags.className, outputPath)
50-
} catch (err) {
51-
throw new CLIError(err)
52-
}
48+
await LuisToTsConverter.writeFromLuisJson(app, flags.className, outputPath)
5349
}
5450
}

packages/luis/src/parser/lufile/exports.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)