forked from constabulary/gb
/
info.go
38 lines (32 loc) · 966 Bytes
/
info.go
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
package main
import (
"fmt"
"path/filepath"
"strings"
"github.com/constabulary/gb"
"github.com/constabulary/gb/cmd"
)
func init() {
registerCommand(&cmd.Command{
Name: "info",
UsageLine: `info`,
Short: "info returns information about this project",
Long: `info returns information about this project.
info returns 0 if the project is well formed, and non zero otherwise.
`,
Run: info,
AddFlags: addBuildFlags,
})
}
func info(ctx *gb.Context, args []string) error {
fmt.Printf("GB_PROJECT_DIR=%q\n", ctx.Projectdir())
fmt.Printf("GB_SRC_PATH=%q\n", joinlist(ctx.Srcdirs()...))
fmt.Printf("GB_PKG_DIR=%q\n", ctx.Pkgdir())
fmt.Printf("GB_BIN_SUFFIX=%q\n", ctx.Suffix())
return nil
}
// joinlist joins path elements using the os specific separator.
// TODO(dfc) it probably gets this wrong on windows in some circumstances.
func joinlist(paths ...string) string {
return strings.Join(paths, string(filepath.ListSeparator))
}