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)
|
log.Fatalf("Error: could not read BPM config: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute subcommand
|
// Show usage if no arguments specified
|
||||||
subcommand := "help"
|
if len(os.Args) == 1 {
|
||||||
if len(os.Args) >= 2 {
|
printUsage()
|
||||||
subcommand = os.Args[1]
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subcommand := os.Args[1]
|
||||||
|
|
||||||
switch subcommand {
|
switch subcommand {
|
||||||
case "v", "version":
|
case "v", "version":
|
||||||
fmt.Println("Bubble Package Manager (BPM)")
|
fmt.Println("Bubble Package Manager (BPM)")
|
||||||
@@ -167,7 +169,8 @@ func main() {
|
|||||||
|
|
||||||
compareVersions()
|
compareVersions()
|
||||||
default:
|
default:
|
||||||
listSubcommands()
|
printUsage()
|
||||||
|
exitCode = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if exitCode != 0 {
|
if exitCode != 0 {
|
||||||
@@ -1285,7 +1288,7 @@ func compareVersions() {
|
|||||||
fmt.Println(bpmlib.CompareVersions(v1, v2))
|
fmt.Println(bpmlib.CompareVersions(v1, v2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func listSubcommands() {
|
func printUsage() {
|
||||||
fmt.Printf("Usage: %s <subcommand> [options]\n", os.Args[0])
|
fmt.Printf("Usage: %s <subcommand> [options]\n", os.Args[0])
|
||||||
fmt.Println("Description: Manage system packages")
|
fmt.Println("Description: Manage system packages")
|
||||||
fmt.Println("Subcommands:")
|
fmt.Println("Subcommands:")
|
||||||
|
|||||||
Reference in New Issue
Block a user