package parsers import ( "regexp" "github.rackspace.com/gorax/tools/util" ) // used with 'show script program' var ( scriptNameRe = regexp.MustCompile(`Script:\s+"(\S+)"\s*\n`) scriptScriptRe = regexp.MustCompile(`Script:\s+"\S+"\s*\n((.|\n)*\})\s*SSH`) ) // AdxScriptContent defines an OpenScript script found on // ADX flash type AdxScriptContent struct { Name string `json:"name"` Script string `json:"content"` } // Parse method is used to implement type population of a given string // using parsers to populate the method receiver. func (a *AdxScriptContent) Parse(s string) { a.Name = util.RegexpFindString(scriptNameRe, s) a.Script = util.RegexpFindString(scriptScriptRe, s) }