mirror of
https://github.com/gabrie30/ghorg.git
synced 2025-08-07 06:47:14 +02:00
* Refactor: save perPage in scm client & use determineClient to load lib clients * infent scm NewClient() * wordings ...
31 lines
547 B
Go
31 lines
547 B
Go
package scm
|
|
|
|
import "fmt"
|
|
|
|
type Client interface {
|
|
NewClient() (Client, error)
|
|
|
|
GetUserRepos(targetUsername string) ([]Repo, error)
|
|
GetOrgRepos(targetOrg string) ([]Repo, error)
|
|
|
|
GetType() string
|
|
}
|
|
|
|
var (
|
|
clients []Client
|
|
)
|
|
|
|
// registerClient registers a client
|
|
func registerClient(c Client) {
|
|
clients = append(clients, c)
|
|
}
|
|
|
|
func GetClient(cType string) (Client, error) {
|
|
for i := range clients {
|
|
if clients[i].GetType() == cType {
|
|
return clients[i].NewClient()
|
|
}
|
|
}
|
|
return nil, fmt.Errorf("client type '%s' unsupported", cType)
|
|
}
|