Rename 'info' subcommand to 'query' and add shorthand for all

subcommands
This commit is contained in:
2025-10-05 16:56:04 +03:00
parent b6d055a38d
commit 91479e58f1
+21 -21
View File
@@ -44,15 +44,15 @@ func main() {
case "version": case "version":
fmt.Println("Bubble Package Manager (BPM)") fmt.Println("Bubble Package Manager (BPM)")
fmt.Println("Version: " + bpmVer) fmt.Println("Version: " + bpmVer)
case "info": case "q", "query":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("info", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("query", flag.ExitOnError)
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory") currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
currentFlagSet.BoolP("database", "d", false, "Show package information from remote databases") currentFlagSet.BoolP("database", "d", false, "Show package information from remote databases")
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Show information on the specified packages", os.Args[2:]) setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Show information on the specified packages", os.Args[2:])
showPackageInfo() showPackageInfo()
case "list": case "l", "list":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("list", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("list", flag.ExitOnError)
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory") currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
@@ -61,13 +61,13 @@ func main() {
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "List packages", os.Args[2:]) setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "List packages", os.Args[2:])
showPackageList() showPackageList()
case "search": case "s", "search":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("search", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("search", flag.ExitOnError)
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Search for packages in remote databases", os.Args[2:]) setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Search for packages in remote databases", os.Args[2:])
searchForPackages() searchForPackages()
case "install": case "i", "install":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("install", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("install", flag.ExitOnError)
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory") currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
@@ -81,7 +81,7 @@ func main() {
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Install the specified packages", os.Args[2:]) setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Install the specified packages", os.Args[2:])
installPackages() installPackages()
case "remove": case "r", "remove":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("remove", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("remove", flag.ExitOnError)
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory") currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
@@ -93,7 +93,7 @@ func main() {
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Remove the specified packages", os.Args[2:]) setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Remove the specified packages", os.Args[2:])
removePackages() removePackages()
case "cleanup": case "n", "cleanup":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("cleanup", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("cleanup", flag.ExitOnError)
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory") currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
@@ -107,7 +107,7 @@ func main() {
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Remove unused dependencies, files and directories", os.Args[2:]) setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Remove unused dependencies, files and directories", os.Args[2:])
doCleanup() doCleanup()
case "sync": case "y", "sync":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("cleanup", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("cleanup", flag.ExitOnError)
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory") currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
@@ -116,7 +116,7 @@ func main() {
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Sync all databases", os.Args[2:]) setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Sync all databases", os.Args[2:])
syncDatabases() syncDatabases()
case "update": case "u", "update":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("update", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("update", flag.ExitOnError)
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory") currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
@@ -128,14 +128,14 @@ func main() {
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Update installed packages", os.Args[2:]) setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Update installed packages", os.Args[2:])
updatePackages() updatePackages()
case "file": case "f", "file":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("file", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("file", flag.ExitOnError)
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory") currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Show what packages own the specified files", os.Args[2:]) setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Show what packages own the specified files", os.Args[2:])
getFileOwner() getFileOwner()
case "compile": case "c", "compile":
// Setup flags and help // Setup flags and help
currentFlagSet = flag.NewFlagSet("compile", flag.ExitOnError) currentFlagSet = flag.NewFlagSet("compile", flag.ExitOnError)
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory") currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
@@ -1054,16 +1054,16 @@ func listSubcommands() {
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:")
fmt.Println(" info Show information on the specified packages") fmt.Println(" q, query Show information on the specified packages")
fmt.Println(" list List packages") fmt.Println(" l, list List packages")
fmt.Println(" search Search for packages in remote databases") fmt.Println(" s, search Search for packages in remote databases")
fmt.Println(" install Install the specified packages") fmt.Println(" i, install Install the specified packages")
fmt.Println(" remove Remove the specified packages") fmt.Println(" r, remove Remove the specified packages")
fmt.Println(" cleanup Remove unused dependencies, files and directories") fmt.Println(" n, cleanup Remove unused dependencies, files and directories")
fmt.Println(" sync Sync all databases") fmt.Println(" y, sync Sync all databases")
fmt.Println(" update Update installed packages") fmt.Println(" u, update Update installed packages")
fmt.Println(" file Show what packages own the specified files") fmt.Println(" f, file Show what packages own the specified files")
fmt.Println(" compile Compile source packages and convert them to binary ones") fmt.Println(" c, compile Compile source packages and convert them to binary ones")
} }
func setupFlagsAndHelp(flagset *flag.FlagSet, usage, desc string, args []string) { func setupFlagsAndHelp(flagset *flag.FlagSet, usage, desc string, args []string) {