MCPcopy
hub / github.com/serverless/serverless / applyConfigurations

Function applyConfigurations

packages/sf-core/src/utils/cli/cli.js:19–45  ·  view source on GitHub ↗
(cliInstance, schemaConfig)

Source from the content-addressed store, hash-verified

17 const cli = yargs(argv).scriptName('')
18
19 const applyConfigurations = (cliInstance, schemaConfig) => {
20 schemaConfig.forEach((config) => {
21 // Handle commands with sub-configurations
22 if (config.command) {
23 cliInstance.command(config.command, config.description, (yargs) => {
24 // Recursively configure sub-commands or options if a builder is provided
25 if (config.builder) {
26 return applyConfigurations(yargs, config.builder)
27 }
28 return yargs
29 })
30 } else {
31 // Dynamically apply configurations for options, positionals, etc.
32 Object.entries(config).forEach(([key, value]) => {
33 // check if the key is a function on the yargs instance
34 if (typeof cliInstance[key] === 'function') {
35 // If a value is an array, assume it's arguments for the yargs method
36 if (Array.isArray(value)) {
37 cliInstance[key](...value)
38 } else {
39 cliInstance[key](value)
40 }
41 }
42 })
43 }
44 })
45 }
46
47 applyConfigurations(cli, schema)
48

Callers 1

validateCliSchemaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…