Add AdvMakefile and .gitm.toml
This commit is contained in:
commit
8269c4bcc1
1
go.mod
1
go.mod
@ -3,6 +3,7 @@ module pak
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/alessio/shellescape v1.4.1
|
||||||
github.com/pelletier/go-toml v1.8.2-0.20201124181426-2e01f733df54
|
github.com/pelletier/go-toml v1.8.2-0.20201124181426-2e01f733df54
|
||||||
github.com/rs/zerolog v1.20.0
|
github.com/rs/zerolog v1.20.0
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
|
22
go.sum
22
go.sum
@ -1,22 +0,0 @@
|
|||||||
gitea.arsenm.dev/Arsen6331/go-tuntox v0.0.0-20210122202525-119d5f454187 h1:5zN850TL+/3lHdUEGbQ29C4KPFwDLodWSaKjLFiWeJk=
|
|
||||||
gitea.arsenm.dev/Arsen6331/go-tuntox v0.0.0-20210122202525-119d5f454187/go.mod h1:88Isb/DdiGw2c82x+cjOOmqyka6Om0DbMRlshjEBG1s=
|
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/pelletier/go-toml v1.8.2-0.20201124181426-2e01f733df54 h1:U7n5zyrdmyUTvXR7DRuSRrdFBkjcIPeCjSG2GScQSL8=
|
|
||||||
github.com/pelletier/go-toml v1.8.2-0.20201124181426-2e01f733df54/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
|
||||||
github.com/rs/zerolog v1.20.0 h1:38k9hgtUBdxFwE34yS8rTHmHBa4eN16E4DJlv177LNs=
|
|
||||||
github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo=
|
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs=
|
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
27
main.go
27
main.go
@ -20,6 +20,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/alessio/shellescape"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
flag "github.com/spf13/pflag"
|
flag "github.com/spf13/pflag"
|
||||||
@ -34,11 +35,9 @@ var Log = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
|||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// Create help flag
|
// Create help flag
|
||||||
var helpFlagGiven bool
|
helpFlagGiven := flag.BoolP("help", "h", false, "Show help screen")
|
||||||
flag.BoolVarP(&helpFlagGiven, "help", "h", false, "Show help screen")
|
|
||||||
// Create package manager override flag
|
// Create package manager override flag
|
||||||
var packageManagerOverride string
|
packageManagerOverride := flag.StringP("package-manager", "p", os.Getenv("PAK_MGR_OVERRIDE"), "Override package manager wrapped by pak")
|
||||||
flag.StringVarP(&packageManagerOverride, "package-manager", "p", os.Getenv("PAK_MGR_OVERRIDE"), "Override package manager wrapped by pak")
|
|
||||||
// Parse arguments for flags
|
// Parse arguments for flags
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -63,9 +62,9 @@ func main() {
|
|||||||
config := NewConfig("/etc/pak.toml")
|
config := NewConfig("/etc/pak.toml")
|
||||||
|
|
||||||
// If override is set
|
// If override is set
|
||||||
if packageManagerOverride != "" {
|
if *packageManagerOverride != "" {
|
||||||
// Set active package manager to override
|
// Set active package manager to override
|
||||||
config.ActiveManager = packageManagerOverride
|
config.ActiveManager = *packageManagerOverride
|
||||||
// Set override state to true
|
// Set override state to true
|
||||||
isOverridden = true
|
isOverridden = true
|
||||||
} else {
|
} else {
|
||||||
@ -93,8 +92,8 @@ func main() {
|
|||||||
similarTo := []string{}
|
similarTo := []string{}
|
||||||
|
|
||||||
// Displays help message if no arguments provided or -h/--help is passed
|
// Displays help message if no arguments provided or -h/--help is passed
|
||||||
if len(args) == 0 || helpFlagGiven || Contains(args, "help") {
|
if len(args) == 0 || *helpFlagGiven || Contains(args, "help") {
|
||||||
printHelpMessage(config.ActiveManager, useRoot, rootCommand, commands, shortcuts, isOverridden)
|
printHelpMessage(config.ActiveManager, rootCommand, commands, shortcuts, useRoot, isOverridden)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,16 +125,14 @@ func main() {
|
|||||||
if len(similarTo) == 0 {
|
if len(similarTo) == 0 {
|
||||||
Log.Fatal().Msg("This command does not match any known commands or shortcuts")
|
Log.Fatal().Msg("This command does not match any known commands or shortcuts")
|
||||||
}
|
}
|
||||||
// Anonymous function to decide whether to print (overridden)
|
var overriddenStr string
|
||||||
printOverridden := func() string {
|
|
||||||
if isOverridden {
|
if isOverridden {
|
||||||
return "(overridden)"
|
overriddenStr = "(overridden)"
|
||||||
} else {
|
} else {
|
||||||
return ""
|
overriddenStr = ""
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Print text showing command being run and package manager being used
|
// Print text showing command being run and package manager being used
|
||||||
fmt.Println("Running:", strings.Title(GetKey(commands, similarTo[0])), "using", strings.Title(config.ActiveManager), printOverridden())
|
fmt.Println("Running:", strings.Title(GetKey(commands, similarTo[0])), "using", strings.Title(config.ActiveManager), overriddenStr)
|
||||||
// Run package manager with the proper arguments passed if more than one argument exists
|
// Run package manager with the proper arguments passed if more than one argument exists
|
||||||
var cmdArr []string
|
var cmdArr []string
|
||||||
// If root is to be used, append it to cmdArr
|
// If root is to be used, append it to cmdArr
|
||||||
@ -152,7 +149,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
// If greater than 2 arguments, append them to cmdArr
|
// If greater than 2 arguments, append them to cmdArr
|
||||||
if len(args) >= 2 {
|
if len(args) >= 2 {
|
||||||
cmdArr = append(cmdArr, strings.Join(args[1:], " "))
|
cmdArr = append(cmdArr, shellescape.QuoteCommand(args[1:]))
|
||||||
}
|
}
|
||||||
// Create space separated string from cmdArr
|
// Create space separated string from cmdArr
|
||||||
cmdStr := strings.Join(cmdArr, " ")
|
cmdStr := strings.Join(cmdArr, " ")
|
||||||
|
2
usage.go
2
usage.go
@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Print help screen
|
// Print help screen
|
||||||
func printHelpMessage(packageManagerCommand string, useRoot bool, rootCommand string, commands map[string]string, shortcuts map[string]string, isOverridden bool) {
|
func printHelpMessage(packageManagerCommand, rootCommand string, commands, shortcuts map[string]string, useRoot, isOverridden bool) {
|
||||||
fmt.Println("Arsen Musayelyan's Package Manager Wrapper")
|
fmt.Println("Arsen Musayelyan's Package Manager Wrapper")
|
||||||
fmt.Print("Current package manager is: ", packageManagerCommand)
|
fmt.Print("Current package manager is: ", packageManagerCommand)
|
||||||
if isOverridden {
|
if isOverridden {
|
||||||
|
Loading…
Reference in New Issue
Block a user