initial dump
This commit is contained in:
parent
b5339485be
commit
448552016b
9 changed files with 617 additions and 11 deletions
59
main.go
Normal file
59
main.go
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.yaml.in/yaml/v4"
|
||||
)
|
||||
|
||||
type Forge struct {
|
||||
Name string `yaml:"name"`
|
||||
Url string `yaml:"url"`
|
||||
Type string `yaml:"type"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Forges []Forge `yaml:"forges"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
data, err := os.ReadFile("config.yaml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var config Config
|
||||
|
||||
if err := yaml.Unmarshal(data, &config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var projects []Project
|
||||
var allProjects []Project
|
||||
for _, forge := range config.Forges {
|
||||
fmt.Printf("%+v: %+v\n", forge.Name, forge.Url)
|
||||
|
||||
switch forge.Type {
|
||||
case "forgejo":
|
||||
scraper, err := NewForgejoScraper(forge.Url)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
projects, err := scraper.GetProjects()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
default:
|
||||
projects = []Project{}
|
||||
fmt.Errorf("unknown forge: %s", forge.Type)
|
||||
}
|
||||
|
||||
fmt.Printf("Found %d repositories\n", len(projects))
|
||||
|
||||
allProjects = append(allProjects, projects...)
|
||||
|
||||
for repo := range allProjects {
|
||||
fmt.Printf("%+v\n", repo)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue