This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprojects.go
More file actions
68 lines (60 loc) · 2.98 KB
/
projects.go
File metadata and controls
68 lines (60 loc) · 2.98 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
68
package main
import (
"fmt"
"os"
"strings"
"github.com/cli/cli/v2/pkg/cmd/factory"
cmdClose "github.com/github/gh-projects/cmd/close"
cmdCopy "github.com/github/gh-projects/cmd/copy"
cmdCreate "github.com/github/gh-projects/cmd/create"
cmdDelete "github.com/github/gh-projects/cmd/delete"
cmdEdit "github.com/github/gh-projects/cmd/edit"
cmdFieldCreate "github.com/github/gh-projects/cmd/field-create"
cmdFieldDelete "github.com/github/gh-projects/cmd/field-delete"
cmdFieldList "github.com/github/gh-projects/cmd/field-list"
cmdItemAdd "github.com/github/gh-projects/cmd/item-add"
cmdItemArchive "github.com/github/gh-projects/cmd/item-archive"
cmdItemCreate "github.com/github/gh-projects/cmd/item-create"
cmdItemDelete "github.com/github/gh-projects/cmd/item-delete"
cmdItemEdit "github.com/github/gh-projects/cmd/item-edit"
cmdItemList "github.com/github/gh-projects/cmd/item-list"
cmdList "github.com/github/gh-projects/cmd/list"
cmdView "github.com/github/gh-projects/cmd/view"
"github.com/spf13/cobra"
)
// analogous to cli/pkg/cmd/pr.go in cli/cli
func main() {
var rootCmd = &cobra.Command{
Use: "projects",
Short: "Work with GitHub Projects.",
Long: "Work with GitHub Projects. Note that the token you are using must have 'project' scope, which is not set by default. You can verify your token scope by running 'gh auth status' and add the project scope by running 'gh auth refresh -s project'.",
SilenceErrors: true,
}
cmdFactory := factory.New("0.1.0") // will be replaced by buildVersion := build.Version
rootCmd.AddCommand(cmdList.NewCmdList(cmdFactory, nil))
rootCmd.AddCommand(cmdCreate.NewCmdCreate(cmdFactory, nil))
rootCmd.AddCommand(cmdCopy.NewCmdCopy(cmdFactory, nil))
rootCmd.AddCommand(cmdClose.NewCmdClose(cmdFactory, nil))
rootCmd.AddCommand(cmdDelete.NewCmdDelete(cmdFactory, nil))
rootCmd.AddCommand(cmdEdit.NewCmdEdit(cmdFactory, nil))
rootCmd.AddCommand(cmdView.NewCmdView(cmdFactory, nil))
// items
rootCmd.AddCommand(cmdItemList.NewCmdList(cmdFactory, nil))
rootCmd.AddCommand(cmdItemCreate.NewCmdCreateItem(cmdFactory, nil))
rootCmd.AddCommand(cmdItemAdd.NewCmdAddItem(cmdFactory, nil))
rootCmd.AddCommand(cmdItemEdit.NewCmdEditItem(cmdFactory, nil))
rootCmd.AddCommand(cmdItemArchive.NewCmdArchiveItem(cmdFactory, nil))
rootCmd.AddCommand(cmdItemDelete.NewCmdDeleteItem(cmdFactory, nil))
// fields
rootCmd.AddCommand(cmdFieldList.NewCmdList(cmdFactory, nil))
rootCmd.AddCommand(cmdFieldCreate.NewCmdCreateField(cmdFactory, nil))
rootCmd.AddCommand(cmdFieldDelete.NewCmdDeleteField(cmdFactory, nil))
if err := rootCmd.Execute(); err != nil {
if strings.HasPrefix(err.Error(), "Message: Your token has not been granted the required scopes to execute this query") {
fmt.Println("Your token has not been granted the required scopes to execute this query.\nRun 'gh auth refresh -s project' to add the 'project' scope.\nRun 'gh auth status' to see your current token scopes.")
os.Exit(1)
}
fmt.Println(err)
os.Exit(1)
}
}