41 lines
772 B
Go
41 lines
772 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"kisekinopureya.com.tr/updater/internal/logger"
|
|
"kisekinopureya.com.tr/updater/internal/version"
|
|
)
|
|
|
|
func main() {
|
|
logger.InitializeLogger("/tmp/os-select-branchlog")
|
|
|
|
log.Printf("%+v", os.Args)
|
|
|
|
if len(os.Args) != 2 {
|
|
fmt.Println("Usage: steamos-select-branch <-stable|unstable|testing>")
|
|
os.Exit(1)
|
|
}
|
|
branchPath := version.BranchPath
|
|
|
|
switch os.Args[1] {
|
|
case "-c":
|
|
branch := version.GetCurrentBranch()
|
|
fmt.Printf("%s\n", branch)
|
|
os.Exit(0)
|
|
case "-l":
|
|
fmt.Printf("%s\n%s\n%s\n", "stable", "unstable", "testing")
|
|
os.Exit(0)
|
|
case "stable", "unstable", "testing":
|
|
err := os.WriteFile(branchPath, []byte(os.Args[1]), 0644)
|
|
if err != nil {
|
|
log.Panic(err)
|
|
}
|
|
os.Exit(0)
|
|
default:
|
|
os.Exit(1)
|
|
}
|
|
}
|