help menu for a node app
require(`yargs`)
.demand(1)
.command(
`detect <input..>`,
`Detects the language of one or more strings.`,
{},
(opts) => detectLanguage(opts.input)
)
.command(
`list [target]`,
`Lists available translation languages. To return language names in a language other than English, specify a target language.`,
{},
(opts) => {
if (opts.target) {
listLanguagesWithTarget(opts.target);
} else {
listLanguages();
}
}
)
.command(
`translate <toLang> <input..>`,
`Translates one or more strings into the target language.`,
{},
(opts) => translateText(opts.input, opts.toLang)
)
.command(
`translate-with-model <toLang> <model> <input..>`,
`Translates one or more strings into the target language using the specified model.`,
{},
(opts) => translateTextWithModel(opts.input, opts.toLang, opts.model)
)
.example(`node $0 detect "Hello world!"`, `Detects the language of a string.`)
.example(`node $0 detect "Hello world!" "Goodbye"`, `Detects the languages of multiple strings.`)
.example(`node $0 list`, `Lists available translation languages with names in English.`)
.example(`node $0 list es`, `Lists available translation languages with names in Spanish.`)
.example(`node $0 translate ru "Good morning!"`, `Translates a string into Russian.`)
.example(`node $0 translate ru "Good morning!" "Good night!"`, `Translates multiple strings into Russian.`)
.example(`node $0 translate-with-model ru nmt "Good morning!" "Good night!"`, `Translates multiple strings into Russian using the Premium model.`)
.wrap(120)
.recommendCommands()
.epilogue(`For more information, see https://cloud.google.com/translate/docs`)
.help()
.strict()
.argv;