Add upgradable flag to list command, bump version, actually add readme content

This commit is contained in:
ferrreo 2023-02-17 13:58:50 +00:00
parent 8e821747d4
commit 7fd8b1804e
3 changed files with 67 additions and 20 deletions

View File

@ -1,2 +1,37 @@
# pikman
PikaOS package manager
# pikman - One package manager to rule them all
## USAGE:
pikman [global options] command [command options] [arguments...]
## VERSION:
v1.23.2.17.0
## COMMANDS:
- **autoremove** - Remove all unused packages
- **clean, cl** - Clean the package manager cache
- **enter** - Enter the container instance for select package manager
- **export** - Export/Recreate a program's desktop entry from the container
- **init** - Initialize a managed container
- **install, i** - Install the specified package(s)
- **list, l** - List installed packages
- **log** - Show package manager logs
- **purge** - Fully purge a package
- **run** - Run a command inside a managed container
- **remove, r** - Remove an installed package
- **search, s** - Search for a package
- **show** - Show details for a package
- **unexport** - Unexport/Remove a program's desktop entry
- **update** - Update the list of available packages
- **upgrade** - Upgrade the system by installing/upgrading available packages
- **help, h** - Shows a list of commands or help for one command
## GLOBAL OPTIONS:
- **--arch, --aur** - Install Arch packages (including from the AUR) (default: false)
- **--fedora, --dnf** - Install Fedora packages (default: false)
- **--alpine, --apk** - Install Alpine packages (default: false)
- **--flatpak, --fl** - Install Flatpak packages (default: false)
- **--name value** - Name of the managed container
- **--help, -h** - show help (default: false)
- **--version, -v** - Version number (default: false)

View File

@ -29,12 +29,16 @@ var packageManagerMap = map[types.OSType]string{
types.Flatpak: flatpak.PackageManager,
}
func ProcessCommand(command string, osType types.OSType, containerName string, packageName []string) error {
func ProcessCommand(command string, osType types.OSType, containerName string, packageName []string, upgradableFlag bool) error {
var err error
if osType != types.Ubuntu && osType != types.Flatpak && containerName != "" {
packageName = append([]string{"--name " + containerName}, packageName...)
}
if osType == types.Ubuntu && upgradableFlag {
packageName = append([]string{"--upgradable"}, packageName...)
}
commandToExecute, err := getCommand(command, osType, packageName)
cmd := exec.Command("/bin/sh", "-c", commandToExecute)
cmd.Stdout = os.Stdout

42
main.go
View File

@ -16,6 +16,7 @@ func main() {
osType := types.Ubuntu
containerName := ""
upgradableFlag := false
cli.VersionFlag = &cli.BoolFlag{
Name: "version",
@ -26,7 +27,7 @@ func main() {
app := &cli.App{
Name: "pikman",
Usage: "One package manager to rule them all",
Version: "v1.23.1.20.0",
Version: "v1.23.2.17.0",
EnableBashCompletion: true,
Flags: []cli.Flag{
&cli.BoolFlag{
@ -84,7 +85,7 @@ func main() {
Name: "autoremove",
Usage: "Remove all unused packages",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
@ -92,28 +93,28 @@ func main() {
Aliases: []string{"cl"},
Usage: "Clean the package manager cache",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
Name: "enter",
Usage: "Enter the container instance for select package manager",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
Name: "export",
Usage: "Export/Recreate a program's desktop entry from the container",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
Name: "init",
Usage: "Initialize a managed container",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
@ -121,36 +122,43 @@ func main() {
Aliases: []string{"i"},
Usage: "Install the specified package(s)",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
Name: "list",
Aliases: []string{"l"},
Usage: "List installed packages",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "upgradable",
Usage: "Used by list to check upgradable packages",
Destination: &upgradableFlag,
},
},
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), upgradableFlag)
},
},
{
Name: "log",
Usage: "Show package manager logs",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
Name: "purge",
Usage: "Fully purge a package",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
Name: "run",
Usage: "Run a command inside a managed container",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
@ -158,7 +166,7 @@ func main() {
Aliases: []string{"r"},
Usage: "Remove an installed package",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
@ -166,28 +174,28 @@ func main() {
Aliases: []string{"s"},
Usage: "Search for a package",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
Name: "show",
Usage: "Show details for a package",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
Name: "unexport",
Usage: "Unexport/Remove a program's desktop entry",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
Name: "update",
Usage: "Update the list of available packages",
Action: func(cCtx *cli.Context) error {
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
{
@ -195,7 +203,7 @@ func main() {
Usage: "Upgrade the system by installing/upgrading available packages",
Action: func(cCtx *cli.Context) error {
cCtx.Args().Tail()
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice())
return loader.ProcessCommand(cCtx.Command.FullName(), osType, containerName, cCtx.Args().Slice(), false)
},
},
},