forked from sourcegraph/src-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeowners.go
More file actions
67 lines (54 loc) · 1.25 KB
/
codeowners.go
File metadata and controls
67 lines (54 loc) · 1.25 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"flag"
"fmt"
"io"
"os"
)
var codeownersCommands commander
func init() {
usage := `'src codeowners' is a tool that manages ingested code ownership data in a Sourcegraph instance.
Usage:
src codeowners command [command options]
The commands are:
get returns the codeowners file for a repository, if exists
create create a codeowners file
update update a codeowners file
delete delete a codeowners file
Use "src codeowners [command] -h" for more information about a command.
`
flagSet := flag.NewFlagSet("codeowners", flag.ExitOnError)
handler := func(args []string) error {
codeownersCommands.run(flagSet, "src codeowners", usage, args)
return nil
}
// Register the command.
commands = append(commands, &command{
flagSet: flagSet,
aliases: []string{"codeowner"},
handler: handler,
usageFunc: func() {
fmt.Println(usage)
},
})
}
const codeownersFragment = `
fragment CodeownersFileFields on CodeownersIngestedFile {
contents
repository {
name
}
}
`
type CodeownersIngestedFile struct {
Contents string `json:"contents"`
Repository struct {
Name string `json:"name"`
} `json:"repository"`
}
func readFile(f string) (io.Reader, error) {
if f == "-" {
return os.Stdin, nil
}
return os.Open(f)
}