forked from Plemya-x/ALR
wip
This commit is contained in:
28
build.go
28
build.go
@@ -23,6 +23,7 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/leonelquinteros/gotext"
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -48,6 +49,11 @@ func BuildCmd() *cli.Command {
|
||||
Value: "alr.sh",
|
||||
Usage: gotext.Get("Path to the build script"),
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "script-package",
|
||||
Aliases: []string{"sp"},
|
||||
Usage: gotext.Get("Specify package in script (for multi package script only)"),
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "package",
|
||||
Aliases: []string{"p"},
|
||||
@@ -79,18 +85,32 @@ func BuildCmd() *cli.Command {
|
||||
switch {
|
||||
case c.IsSet("script"):
|
||||
script = c.String("script")
|
||||
packageName = c.String("script-package")
|
||||
case c.IsSet("package"):
|
||||
// TODO: refactor
|
||||
// TODO: handle multiple packages
|
||||
packageInput := c.String("package")
|
||||
pkgs, _, _ := rs.FindPkgs(ctx, []string{packageInput})
|
||||
pkg := pkgs[packageInput]
|
||||
|
||||
arr := strings.Split(packageInput, "/")
|
||||
var packageSearch string
|
||||
if len(arr) == 2 {
|
||||
packageSearch = arr[1]
|
||||
} else {
|
||||
packageSearch = arr[0]
|
||||
}
|
||||
|
||||
pkgs, _, _ := rs.FindPkgs(ctx, []string{packageSearch})
|
||||
pkg, ok := pkgs[packageSearch]
|
||||
if len(pkg) < 1 || !ok {
|
||||
slog.Error(gotext.Get("Package not found"))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if pkg[0].BasePkgName != "" {
|
||||
script = filepath.Join(repoDir, pkg[0].Repository, pkg[0].BasePkgName, "alr.sh")
|
||||
packageName = pkg[0].Name
|
||||
} else {
|
||||
script = filepath.Join(repoDir, pkg[0].Repository, pkg[0].Name, "alr.sh")
|
||||
}
|
||||
|
||||
default:
|
||||
script = filepath.Join(repoDir, "alr.sh")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user