local ExtUtils = {} local cjson = require "cjson" function ExtUtils.slurpFile( name ) local f = assert( io.open( name, "rb" ) ) local content = f:read( "*all" ) f:close() return content end function ExtUtils.writeFile( name, content ) local f = assert( io.open( name, "w" ) ) local content = f:write( content ) f:close() end function getManifest() local fn = Helix.Core.Server.GetArchDirFileName( "manifest.json" ) return cjson.decode( ExtUtils.slurpFile( fn ) ) end function trim( s ) return ( s:gsub( "^%s*(.-)%s*$", "%1" ) ) end function getICfg() local cfg = {} for k, v in pairs( Helix.Core.Server.GetInstanceConfigData() ) do cfg[ k ] = trim( v ) end return cfg end function ExtUtils.msgHeader() return ExtUtils.manifest[ "name" ] .. "/" .. ExtUtils.manifest[ "key" ] .. "/" .. ExtUtils.manifest[ "version_name" ] .. ": " end ExtUtils.manifest = {} ExtUtils.iCfgData = {} function ExtUtils.init() if ExtUtils.iCfgData[ "specName" ] == nil then ExtUtils.iCfgData = getICfg() -- todo: split the user list into another table end if ExtUtils.manifest[ "key" ] == nil then ExtUtils.manifest = getManifest() end end return ExtUtils
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 30808 | C. Thomas Tyler |
Promoted from 2019.1/... to main/... |
||
//guest/perforce_software/extensions/2019.1/spec_pretty_printer/ExtUtils.lua | |||||
#1 | 25601 | Jason Gibson |
Import example Extensions. p19.1@1797741 |