Skip to content

Commit

Permalink
Merge pull request #47 from saludangelito/cli
Browse files Browse the repository at this point in the history
Added a checker if optionality required in addition to map type
  • Loading branch information
iamEAP authored Feb 11, 2020
2 parents 1103794 + 19ca8af commit 1865217
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/step-aware-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,31 @@ export default abstract class extends RegistryAwareCommand {
})
expectedFields.forEach(field => {
if (field.type === FieldDefinition.Type.ANYNONSCALAR || field.type === FieldDefinition.Type.MAP) {
prompts.next({
name: `:internal:confirm:${field.key}`,
message: `Add ${field.key} fields?`,
type: 'confirm'
})
if (field.optionality === FieldDefinition.Optionality.OPTIONAL) {
prompts.next({
name: `:internal:confirm:${field.key}`,
message: `Add ${field.key} fields?`,
type: 'confirm'
})
} else {
prompts.next({
name: `nonscalar.${field.key}.key`,
message: `${field.key} object key`,
type: 'input',
default: field.optionality === FieldDefinition.Optionality.OPTIONAL ? optionalMsg : null,
})
prompts.next({
name: `nonscalar.${field.key}.value`,
message: `${field.key} object value`,
type: 'input',
default: field.optionality === FieldDefinition.Optionality.OPTIONAL ? optionalMsg : null,
})
prompts.next({
name: ':internal:confirm:',
message: `Add another ${field.key} field?`,
type: 'confirm'
})
}
hasObjectNeed = true
} else {
prompts.next({
Expand Down

0 comments on commit 1865217

Please sign in to comment.