// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.

package tangled

// schema: sh.tangled.repo.languages

import (
	"context"

	"github.com/bluesky-social/indigo/lex/util"
)

const (
	RepoLanguagesNSID = "sh.tangled.repo.languages"
)

// RepoLanguages_Language is a "language" in the sh.tangled.repo.languages schema.
type RepoLanguages_Language struct {
	// color: Hex color code for this language
	Color *string `json:"color,omitempty" cborgen:"color,omitempty"`
	// extensions: File extensions associated with this language
	Extensions []string `json:"extensions,omitempty" cborgen:"extensions,omitempty"`
	// fileCount: Number of files in this language
	FileCount *int64 `json:"fileCount,omitempty" cborgen:"fileCount,omitempty"`
	// name: Programming language name
	Name string `json:"name" cborgen:"name"`
	// percentage: Percentage of total codebase (0-100)
	Percentage int64 `json:"percentage" cborgen:"percentage"`
	// size: Total size of files in this language (bytes)
	Size int64 `json:"size" cborgen:"size"`
}

// RepoLanguages_Output is the output of a sh.tangled.repo.languages call.
type RepoLanguages_Output struct {
	Languages []*RepoLanguages_Language `json:"languages" cborgen:"languages"`
	// ref: The git reference used
	Ref string `json:"ref" cborgen:"ref"`
	// totalFiles: Total number of files analyzed
	TotalFiles *int64 `json:"totalFiles,omitempty" cborgen:"totalFiles,omitempty"`
	// totalSize: Total size of all analyzed files in bytes
	TotalSize *int64 `json:"totalSize,omitempty" cborgen:"totalSize,omitempty"`
}

// RepoLanguages calls the XRPC method "sh.tangled.repo.languages".
//
// ref: Git reference (branch, tag, or commit SHA)
// repo: Repository identifier in format 'did:plc:.../repoName'
func RepoLanguages(ctx context.Context, c util.LexClient, ref string, repo string) (*RepoLanguages_Output, error) {
	var out RepoLanguages_Output

	params := map[string]interface{}{}
	if ref != "" {
		params["ref"] = ref
	}
	params["repo"] = repo
	if err := c.LexDo(ctx, util.Query, "", "sh.tangled.repo.languages", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
