added -o flag to specify output for package
This commit is contained in:
parent
596fd888cc
commit
b64650e114
1 changed files with 27 additions and 1 deletions
28
cmd/main.go
28
cmd/main.go
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.oreonproject.org/oreonproject/eternity/common"
|
"git.oreonproject.org/oreonproject/eternity/common"
|
||||||
"git.oreonproject.org/oreonproject/eternity/lib"
|
"git.oreonproject.org/oreonproject/eternity/lib"
|
||||||
|
@ -40,6 +41,31 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow the user to choose an output dir
|
||||||
|
var outputDir = "./" // Default output directory
|
||||||
|
|
||||||
|
// Loop through arguments to find "-o" or "--output"
|
||||||
|
for i := 2; i < len(os.Args); i++ {
|
||||||
|
if os.Args[i] == "-o" || os.Args[i] == "--output" {
|
||||||
|
// Check if next argument exists and is not another flag
|
||||||
|
if i+1 < len(os.Args) && !strings.HasPrefix(os.Args[i+1], "-") {
|
||||||
|
outputDir = os.Args[i+1]
|
||||||
|
if !filepath.IsAbs(outputDir) {
|
||||||
|
outputDir, _ = filepath.Abs(outputDir) // Convert to absolute path if relative
|
||||||
|
}
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
fmt.Println("FATAL: Output directory not specified or invalid after", os.Args[i])
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogFunc(lib.Log{
|
||||||
|
Level: "INFO",
|
||||||
|
Content: "Build directory set to: " + outputDir,
|
||||||
|
})
|
||||||
|
|
||||||
privateKey, err, vagueError := common.LoadPrivateKey(logger)
|
privateKey, err, vagueError := common.LoadPrivateKey(logger)
|
||||||
if err != nil || vagueError != nil {
|
if err != nil || vagueError != nil {
|
||||||
common.LoadPrivateKeyHandleError(err, vagueError, logger)
|
common.LoadPrivateKeyHandleError(err, vagueError, logger)
|
||||||
|
@ -66,7 +92,7 @@ func main() {
|
||||||
if err != nil || vagueError != nil {
|
if err != nil || vagueError != nil {
|
||||||
common.BuildEPKHandleError(tempDir, err, vagueError, logger)
|
common.BuildEPKHandleError(tempDir, err, vagueError, logger)
|
||||||
} else {
|
} else {
|
||||||
filePath := filepath.Join("./", config.Metadata.Name+"-"+config.Metadata.Version.String())
|
filePath := filepath.Join(outputDir, config.Metadata.Name+"-"+config.Metadata.Version.String())
|
||||||
config.Metadata.DecompressedSize = size
|
config.Metadata.DecompressedSize = size
|
||||||
err, vagueError := lib.PackageEPK(config.Metadata, config.Build, tempDir, filePath+".epk", privateKey, logger)
|
err, vagueError := lib.PackageEPK(config.Metadata, config.Build, tempDir, filePath+".epk", privateKey, logger)
|
||||||
if err != nil || vagueError != nil {
|
if err != nil || vagueError != nil {
|
||||||
|
|
Loading…
Reference in a new issue