MCPcopy Create free account
hub / github.com/dropbox/dbxcli / commandInputSchemaFor

Function commandInputSchemaFor

cmd/help_input_schema.go:10–84  ·  view source on GitHub ↗
(args []jsonCommandArg, flags []jsonCommandFlag)

Source from the content-addressed store, hash-verified

8)
9
10func commandInputSchemaFor(args []jsonCommandArg, flags []jsonCommandFlag) jsonCommandInputSchema {
11 schema := jsonCommandInputSchema{
12 Type: "object",
13 AdditionalProperties: false,
14 Required: []string{},
15 Properties: map[string]jsonCommandInputProperty{},
16 }
17
18 for _, arg := range args {
19 name := commandInputPropertyName(arg.Name)
20 property := jsonCommandInputProperty{
21 Type: commandInputPropertyType(arg.ValueKind, ""),
22 Description: arg.Description,
23 Enum: sortedCopyStringSlice(arg.EnumValues),
24 XCLIKind: "arg",
25 XCLIName: arg.Name,
26 XValueKind: arg.ValueKind,
27 XStreamDash: arg.StreamDash,
28 }
29 if arg.Variadic {
30 property.Type = "array"
31 property.Items = &jsonCommandInputProperty{
32 Type: commandInputPropertyType(arg.ValueKind, ""),
33 Enum: sortedCopyStringSlice(arg.EnumValues),
34 }
35 property.Enum = nil
36 if arg.Required {
37 property.MinItems = 1
38 }
39 }
40 if format := commandInputPropertyFormat(arg.ValueKind); format != "" && !arg.Variadic {
41 property.Format = format
42 }
43 schema.Properties[name] = property
44 if arg.Required {
45 schema.Required = append(schema.Required, name)
46 }
47 }
48
49 for _, flag := range flags {
50 if !commandInputSchemaIncludesFlag(flag) {
51 continue
52 }
53 name := commandInputPropertyName(flag.Name)
54 propertyType := commandInputPropertyType(flag.ValueKind, flag.Type)
55 property := jsonCommandInputProperty{
56 Type: propertyType,
57 Description: flag.Usage,
58 Enum: sortedCopyStringSlice(flag.EnumValues),
59 XCLIKind: "flag",
60 XCLIName: flag.Name,
61 XValueKind: flag.ValueKind,
62 XSensitive: flag.Sensitive,
63 XConflicts: commandInputPropertyNames(flag.Conflicts),
64 XInherited: flag.Inherited,
65 XShorthand: flag.Shorthand,
66 XMayPrompt: flag.MayPrompt,
67 }

Callers 1

jsonCommandManifestForFunction · 0.85

Calls 7

commandInputPropertyNameFunction · 0.85
commandInputPropertyTypeFunction · 0.85
sortedCopyStringSliceFunction · 0.85
commandInputFlagDefaultFunction · 0.85

Tested by

no test coverage detected