-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_example_test.go
More file actions
47 lines (41 loc) · 1.15 KB
/
app_example_test.go
File metadata and controls
47 lines (41 loc) · 1.15 KB
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
package core_test
import . "dappco.re/go"
// ExampleApp_New builds application metadata from name, version, description, and binary
// filename options. Application metadata is registered once and found later by stable names.
func ExampleApp_New() {
app := App{}.New(NewOptions(
Option{Key: "name", Value: "forge"},
Option{Key: "version", Value: "1.2.3"},
Option{Key: "description", Value: "deployment tool"},
Option{Key: "filename", Value: "forge"},
))
Println(app.Name)
Println(app.Version)
Println(app.Description)
Println(app.Filename)
// Output:
// forge
// 1.2.3
// deployment tool
// forge
}
// ExampleApp_Find resolves application metadata from an executable path and display name.
// Application metadata is registered once and found later by stable names.
func ExampleApp_Find() {
fs := (&Fs{}).New("/")
dir := fs.TempDir("core-app-example")
defer fs.DeleteAll(dir)
bin := Path(dir, "forge")
fs.WriteMode(bin, "#!/bin/sh\n", 0755)
r := App{}.Find(bin, "Forge")
app := r.Value.(*App)
Println(r.OK)
Println(app.Name)
Println(PathBase(app.Filename))
Println(PathBase(app.Path))
// Output:
// true
// Forge
// forge
// forge
}