Skip to content

Commit abc1063

Browse files
authored
Merge pull request #209 from kcl-lang/entry-set-api
feat: add entry set APIs
2 parents f6f6493 + 654cafd commit abc1063

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/opt/opt.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ func (opts *CompileOptions) ExtendEntries(entries []string) {
5252
opts.entries = append(opts.entries, entries...)
5353
}
5454

55+
// SetEntries will set the entries of the compiler.
56+
func (opts *CompileOptions) SetEntries(entries []string) {
57+
opts.entries = entries
58+
}
59+
5560
// SetHasSettingsYaml will set the 'hasSettingsYaml' flag.
5661
func (opts *CompileOptions) SetHasSettingsYaml(hasSettingsYaml bool) {
5762
opts.hasSettingsYaml = hasSettingsYaml

pkg/opt/opt_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ func TestWorkDirAsPkgPath(t *testing.T) {
1414
assert.Equal(t, opts.PkgPath(), "")
1515
opts.Merge(kcl.WithWorkDir("test_work_dir"))
1616
assert.Equal(t, opts.PkgPath(), "test_work_dir")
17+
opts.ExtendEntries([]string{"file1.k", "file2.k"})
18+
opts.ExtendEntries([]string{"file3.k", "file4.k"})
19+
assert.Equal(t, opts.Entries(), []string{"file1.k", "file2.k", "file3.k", "file4.k"})
20+
opts.SetEntries([]string{"override.k"})
21+
assert.Equal(t, opts.Entries(), []string{"override.k"})
1722
}

0 commit comments

Comments
 (0)