blob: dbaa8be04b6384cf731713a2879e3e4f9205a639 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// SPDX-FileCopyrightText: 2019 M. Shulhan <ms@kilabit.info>
// SPDX-License-Identifier: GPL-3.0-or-later
//go:build !integration
package awwan
import (
"fmt"
"log"
)
func ExampleParseScript() {
var (
envContent = `
[section]
key=value
`
scriptContent = `
multiline \
command {{.Val "section::key"}}; \
end;
`
ses = &Session{}
s *Script
err error
stmt []byte
)
err = ses.loadRawEnv([]byte(envContent))
if err != nil {
log.Fatal(err)
}
s, err = ParseScript(ses, `scriptContent`, []byte(scriptContent))
if err != nil {
log.Fatal(err)
}
for _, stmt = range s.rawLines {
fmt.Printf("%s\n", stmt)
}
// Output:
//
// multiline command value; end;
//
//
}
|