Provide flag for passing package manager arguments
This commit is contained in:
parent
da0be8eb0f
commit
66259e28c6
15
main.go
15
main.go
|
@ -23,6 +23,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
|
@ -31,6 +32,7 @@ import (
|
|||
"go.arsenm.dev/logger/log"
|
||||
"go.arsenm.dev/lure/internal/config"
|
||||
"go.arsenm.dev/lure/internal/db"
|
||||
"go.arsenm.dev/lure/manager"
|
||||
)
|
||||
|
||||
//go:generate scripts/gen-version.sh
|
||||
|
@ -54,6 +56,13 @@ func main() {
|
|||
app := &cli.App{
|
||||
Name: "lure",
|
||||
Usage: "Linux User REpository",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "pm-args",
|
||||
Aliases: []string{"P"},
|
||||
Usage: "Arguments to be passed on to the package manager",
|
||||
},
|
||||
},
|
||||
Commands: []*cli.Command{
|
||||
{
|
||||
Name: "install",
|
||||
|
@ -155,6 +164,12 @@ func main() {
|
|||
Action: displayVersion,
|
||||
},
|
||||
},
|
||||
Before: func(c *cli.Context) error {
|
||||
fmt.Println("pm-args:", c.String("pm-args"))
|
||||
args := strings.Split(c.String("pm-args"), " ")
|
||||
manager.Args = append(manager.Args, args...)
|
||||
return nil
|
||||
},
|
||||
After: func(ctx *cli.Context) error {
|
||||
return gdb.Close()
|
||||
},
|
||||
|
|
|
@ -23,6 +23,8 @@ import (
|
|||
"os/exec"
|
||||
)
|
||||
|
||||
var Args []string
|
||||
|
||||
type Opts struct {
|
||||
AsRoot bool
|
||||
NoConfirm bool
|
||||
|
@ -115,7 +117,8 @@ func setCmdEnv(cmd *exec.Cmd) {
|
|||
|
||||
func ensureOpts(opts *Opts) *Opts {
|
||||
if opts == nil {
|
||||
return DefaultOpts
|
||||
opts = DefaultOpts
|
||||
}
|
||||
opts.Args = append(opts.Args, Args...)
|
||||
return opts
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue