// Copyright (C) 2023 The Licensing Authors // SPDX-License-Identifier: MIT package main import ( "flag" "os" "text/template" "github.com/Masterminds/sprig/v3" ) const readme = ` {{- $gitea := .BaseURL.Gitea -}} {{- $woodpecker := .BaseURL.Woodpecker -}}

⚒️ Libraries ⚒️

| Language | Repository | Build Pipeline | |----------|------------|----------------| {{- range .Libraries }} | {{ .Language }} | [{{ .Repository }}]({{ $gitea }}/{{ .Repository }}) | [![status-badge]({{ $woodpecker }}/api/badges/{{ .Build }}/status.svg)]({{ $woodpecker }}/repos/{{ .Build }}) | {{- end }}

⚒️ Tools and Technologies ⚒️

{{- range .Tools }} {{- range . }} {{ .Name }}  {{- end }}
{{- end }}



` type BaseURL struct { Gitea string Woodpecker string } type Library struct { Language string Repository string Build string } type Tool struct { Name string Devicon string } type TemplateData struct { BaseURL BaseURL Libraries []Library Tools [][]Tool } func main() { cli := flag.NewFlagSet("gen-readme", flag.ExitOnError) cli.SetOutput(os.Stderr) output := cli.String("", "-", "") err := cli.Parse(os.Args[1:]) if err != nil { panic(err) } out := os.Stdout if output != nil && *output != "" && *output != "-" { out, err = os.Create(*output) if err != nil { panic(err) } defer out.Close() } t := template.Must( template.New("readme"). Funcs(sprig.TxtFuncMap()). Parse(readme), ) err = t.Execute(out, TemplateData{ BaseURL: BaseURL{ Gitea: "https://code.pitz.tech", Woodpecker: "https://build.pitz.tech", }, Libraries: []Library{ {"Protobuf", "licensing/proto", "1"}, {"Golang", "licensing/api-go", "2"}, {"Rust", "licensing/api-rust", "3"}, {"NodeJS", "licensing/api-node", ""}, }, Tools: [][]Tool{ { {"Git", "git/git-plain"}, }, { {"Go", "go/go-original"}, {"Rust", "rust/rust-plain"}, {"NodeJS", "nodejs/nodejs-original"}, {"TypeScript", "typescript/typescript-original"}, }, { {"SQLite", "sqlite/sqlite-original"}, {"PostgreSQL", "postgresql/postgresql-original"}, {"Redis", "redis/redis-original"}, }, { {"Prometheus", "prometheus/prometheus-original"}, {"Grafana", "grafana/grafana-original"}, }, }, }) if err != nil { panic(err) } }