11package project
22
33import (
4+ "encoding/json"
5+ "fmt"
46 "net/http"
57
8+ "github.com/cli/cli/api"
69 "github.com/cli/cli/internal/ghrepo"
710 "github.com/cli/cli/pkg/cmdutil"
811 "github.com/cli/cli/pkg/iostreams"
@@ -29,14 +32,11 @@ func NewCmdProject(f *cmdutil.Factory, runF func(*ProjectOptions) error) *cobra.
2932 Short : "Interact with a GitHub project" ,
3033 Long : "Enter an interactive UI for viewing and modifying a GitHub project" ,
3134 Hidden : true ,
32- Args : cobra .MaximumNArgs ( 1 ) ,
35+ Args : cobra .NoArgs ,
3336 RunE : func (c * cobra.Command , args []string ) error {
3437 // support `-R, --repo` override
3538 opts .BaseRepo = f .BaseRepo
3639
37- if len (args ) > 0 {
38- opts .Selector = args [0 ]
39- }
4040 if runF != nil {
4141 return runF (& opts )
4242 }
@@ -48,5 +48,46 @@ func NewCmdProject(f *cmdutil.Factory, runF func(*ProjectOptions) error) *cobra.
4848}
4949
5050func projectRun (opts * ProjectOptions ) error {
51+ // TODO interactively ask which project they want since these IDs are not easy to get
52+ projectID := "3514315"
53+
54+ c , err := opts .HttpClient ()
55+ if err != nil {
56+ return err
57+ }
58+ client := api .NewClientFromHTTP (c )
59+
60+ baseRepo , err := opts .BaseRepo ()
61+ if err != nil {
62+ return err
63+ }
64+
65+ project , err := getProject (client , baseRepo , projectID )
66+ if err != nil {
67+ return err
68+ }
69+
70+ fmt .Printf ("DBG %#v\n " , project )
71+
5172 return nil
5273}
74+
75+ type Project struct {
76+ Name string
77+ }
78+
79+ func getProject (client * api.Client , baseRepo ghrepo.Interface , projectID string ) (* Project , error ) {
80+ data , err := client .GetProject (baseRepo , projectID )
81+ if err != nil {
82+ return nil , err
83+ }
84+
85+ project := & Project {}
86+
87+ err = json .Unmarshal (data , project )
88+ if err != nil {
89+ return nil , err
90+ }
91+
92+ return project , nil
93+ }
0 commit comments