Null-DRM-Official/apps/cli/modulescmd/modulescmd.go
404errordeveloper f9c28be3f1
All checks were successful
release / build-and-upload (push) Successful in 6m8s
modules-release / build-and-upload (push) Successful in 4m47s
v0.1.1: external modules, publish YAML, proxy reset, binary-first README
- Host discovers/builds modules under modules/ (bbc, rte, tg4)
- module-publish.yaml tracked; local module.yaml gitignored
- drm --modules-dir / DRM_MODULES_DIR
- drm proxy reset; Magisk reinject reliability
- modules-v* Forgejo release workflow + build scripts
- BBC full Explore channel map including S4C
- README quickstart based on release binaries
2026-10-08 23:16:14 +02:00

81 lines
2 KiB
Go

// Package modulescmd lists provider modules discovered under modules/<name>/,
// building them on demand and showing channels + values paths.
package modulescmd
import (
"flag"
"fmt"
"os"
"sort"
"text/tabwriter"
"drmdecryption/modhost"
"drmdecryption/repo"
)
// Run prints external modules under modules/.
func Run(args []string) error {
fs := flag.NewFlagSet("modules", flag.ExitOnError)
verbose := fs.Bool("channels", true, "list each module's channels")
if err := fs.Parse(args); err != nil {
return err
}
root := repo.Root()
listed, err := modhost.ListAll(root)
if err != nil {
return err
}
if len(listed) == 0 {
return fmt.Errorf("no modules found under %s — add modules/<name>/ with Go source + module.yaml (see modules/README.md)", modhost.ModulesDir(root))
}
tw := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
fmt.Fprintln(tw, "APP\tPACKAGE\tKEY MODE\tREWRITER\tCHANNELS\tVALUES")
for _, L := range listed {
d := L.Desc
rewriter := d.Rewriter
if rewriter == "" {
rewriter = "none"
}
pkg := d.Package
if pkg == "" {
pkg = "(not configured)"
}
values := d.ValuesPath
if values == "" {
values = L.Mod.Dir + string(os.PathSeparator) + "module.yaml"
}
if _, err := os.Stat(values); err != nil {
values = "missing: " + values
} else if !d.ValuesLoaded {
values = values + " (not loaded)"
}
fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%d\t%s\n",
d.Name, pkg, d.KeyMode, rewriter, len(d.Channels), values)
}
_ = tw.Flush()
if !*verbose {
return nil
}
for _, L := range listed {
d := L.Desc
chans := append([]modhost.Channel{}, d.Channels...)
sort.Slice(chans, func(i, j int) bool { return chans[i].ID < chans[j].ID })
fmt.Printf("\n%s channels:", d.Name)
if len(chans) == 0 {
fmt.Printf(" none — add %s\n", d.ValuesPath)
continue
}
fmt.Println()
for _, ch := range chans {
catalog := ""
if d.HasCatalog {
catalog = " (catalog)"
}
fmt.Printf(" %-10s %s%s\n", ch.ID, ch.Label, catalog)
}
}
return nil
}