MCPcopy
hub / github.com/serverless/serverless / extractCommandsAndOptions

Function extractCommandsAndOptions

packages/sf-core/src/utils/cli/cli.js:110–131  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

108 * Get "command" and "options" from argv
109 */
110const extractCommandsAndOptions = (argv) => {
111 const command = argv._
112 const options = argv
113 delete options._
114 delete options.$0
115 if (options.debug === true) {
116 options.debug = '*'
117 }
118
119 // Normalize multi-value options for specific commands.
120 // For "invoke local", ensure --env / -e are always treated as arrays,
121 // matching the "multiple" type in the Framework command schema.
122 if (command[0] === 'invoke' && command[1] === 'local') {
123 if (options.env && !Array.isArray(options.env)) {
124 options.env = [options.env]
125 }
126 if (options.e && !Array.isArray(options.e)) {
127 options.e = [options.e]
128 }
129 }
130 return { command, options }
131}
132
133export { validateCliSchema, commandExist, extractCommandsAndOptions }

Callers 3

runFunction · 0.90
validateCliSchemaFunction · 0.85
cli.test.jsFile · 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…