schema

package
v0.0.0-...-7bc1492 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

You can use the following json example. It will prompt for all 4 properties and tell you that 3 of them are required :

{  
   "type":"object",
   "properties":{  
      "server":{  
         "type":"string"
      },
      "port":{  
         "type":"integer"
      },
      "userid":{  
         "type":"integer"
      },
      "password":{  
         "type":"string"
      }
   },
   "required":[  
      "server",
      "port",
	  "password"
   ]
}

The output of schema parsing looks like this (with values entered by hand):

Insert string value for /server [required]> 127.0.0.1

Insert integer value for /port [required]> 8111

Insert integer value for /userid> 0

Insert string value for /password [required]>

Other possible types are "number" and "boolean".

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser struct definition

func NewSchemaParser

func NewSchemaParser(userInterface *termui.UI) *Parser

NewSchemaParser initializes SchemaParser

func (*Parser) ParseSchema

func (p *Parser) ParseSchema(schema string) (string, error)

ParseSchema parses a json string and prompts the user for the types defined in the json (string/number/integer/boolean)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL