Skip to content

Commit

Permalink
[ADD] automatic configuration with isc.json
Browse files Browse the repository at this point in the history
  • Loading branch information
gevorg95 committed Jul 31, 2018
1 parent 41384bc commit 6d84057
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cls/dev/code.cls
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ ClassMethod setIgnore(ByRef filtermask)
/// get or set working directory for export/import source
ClassMethod workdir(workdir)
{
s gln = ..gln() s:$d(workdir) @gln = workdir
set:$d(workdir) workdir = ##class(%File).NormalizeDirectory(workdir)
s gln = ..gln()
s:$d(workdir) @gln = workdir

///zu(12) namespace directory by default
#define nsdir $zu(12,"")
Q $g(@gln, $$$nsdir)
Expand All @@ -272,13 +275,17 @@ ClassMethod gln() [ CodeMode = expression, Private ]
"^"_$classname()
}

ClassMethod init(confile = "isc.json")
ClassMethod init(confile = "isc.json") [ CodeMode = objectgenerator ]
{
set stream=##class(%Stream.FileCharacter).%New()
set sc=stream.LinkToFile(..workdir()_"/"_confile)
s:$g(confile)="" confile = "isc.json"
q:..workdir()=""
q:'##class(%File).Exists(..workdir()_confile) $$$OK

s stream=##class(%Stream.FileCharacter).%New()
s sc=stream.LinkToFile(..workdir()_confile)
s conf={}.%FromJSON(stream.Read($$$MaxCacheInt))

s gln=..gln()
s gln = "^"_%class.Name

s @gln@("compileList")=conf.compileList
s @gln@("projectName")=conf.projectName
Expand All @@ -287,6 +294,7 @@ ClassMethod init(confile = "isc.json")
s @gln@("user")=conf.user
s @gln@("password")=conf.password
s @gln@("git")=conf.git
s:@gln@("git")="" @gln@("git")=0

w "compileList="_conf.compileList,!
w "projectName="_conf.projectName,!
Expand All @@ -299,12 +307,6 @@ ClassMethod init(confile = "isc.json")
quit $$$OK
}

ClassMethod initDefaultValue() [ CodeMode = objectgenerator ]
{
s gln = "^"_%class.Name
s @gln@("git")=0
}

/// export release file for list and project settings
ClassMethod release()
{
Expand Down

0 comments on commit 6d84057

Please sign in to comment.