mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 02:26:12 +00:00
Exit with exit code 1 if no valid subcommand is specified
This commit is contained in:
+9
-6
@@ -36,12 +36,14 @@ func main() {
|
||||
log.Fatalf("Error: could not read BPM config: %s", err)
|
||||
}
|
||||
|
||||
// Execute subcommand
|
||||
subcommand := "help"
|
||||
if len(os.Args) >= 2 {
|
||||
subcommand = os.Args[1]
|
||||
// Show usage if no arguments specified
|
||||
if len(os.Args) == 1 {
|
||||
printUsage()
|
||||
return
|
||||
}
|
||||
|
||||
subcommand := os.Args[1]
|
||||
|
||||
switch subcommand {
|
||||
case "v", "version":
|
||||
fmt.Println("Bubble Package Manager (BPM)")
|
||||
@@ -167,7 +169,8 @@ func main() {
|
||||
|
||||
compareVersions()
|
||||
default:
|
||||
listSubcommands()
|
||||
printUsage()
|
||||
exitCode = 1
|
||||
}
|
||||
|
||||
if exitCode != 0 {
|
||||
@@ -1285,7 +1288,7 @@ func compareVersions() {
|
||||
fmt.Println(bpmlib.CompareVersions(v1, v2))
|
||||
}
|
||||
|
||||
func listSubcommands() {
|
||||
func printUsage() {
|
||||
fmt.Printf("Usage: %s <subcommand> [options]\n", os.Args[0])
|
||||
fmt.Println("Description: Manage system packages")
|
||||
fmt.Println("Subcommands:")
|
||||
|
||||
Reference in New Issue
Block a user