mirror of
https://github.com/Jguer/yay.git
synced 2025-12-27 10:01:53 -05:00
catch incompatible --clean flag when no operation is specified with better error message (#2644)
* improve error messaging when running yay -c * use correct method in parsing -c flag * better express prefixes in --help
This commit is contained in:
2
clean.go
2
clean.go
@@ -52,7 +52,7 @@ func syncClean(ctx context.Context, run *runtime.Runtime, cmdArgs *parser.Argume
|
|||||||
keepInstalled := false
|
keepInstalled := false
|
||||||
keepCurrent := false
|
keepCurrent := false
|
||||||
|
|
||||||
_, removeAll, _ := cmdArgs.GetArg("c", "clean")
|
removeAll := cmdArgs.ExistsArg("c", "clean")
|
||||||
|
|
||||||
for _, v := range run.PacmanConf.CleanMethod {
|
for _, v := range run.PacmanConf.CleanMethod {
|
||||||
switch v {
|
switch v {
|
||||||
|
|||||||
8
cmd.go
8
cmd.go
@@ -51,7 +51,7 @@ New operations:
|
|||||||
yay {-Y --yay} [options] [package(s)]
|
yay {-Y --yay} [options] [package(s)]
|
||||||
|
|
||||||
If no operation is specified 'yay -Syu' will be performed
|
If no operation is specified 'yay -Syu' will be performed
|
||||||
If no operation is specified and targets are provided -Y will be assumed
|
If no operation is specified and targets are provided, -Y will be assumed
|
||||||
|
|
||||||
New options:
|
New options:
|
||||||
-N --repo Assume targets are from the repositories
|
-N --repo Assume targets are from the repositories
|
||||||
@@ -122,18 +122,18 @@ Permanent configuration options:
|
|||||||
|
|
||||||
--timeupdate Check packages' AUR page for changes during sysupgrade
|
--timeupdate Check packages' AUR page for changes during sysupgrade
|
||||||
|
|
||||||
show specific options:
|
show specific options (used with -P):
|
||||||
-c --complete Used for completions
|
-c --complete Used for completions
|
||||||
-d --defaultconfig Print default yay configuration
|
-d --defaultconfig Print default yay configuration
|
||||||
-g --currentconfig Print current yay configuration
|
-g --currentconfig Print current yay configuration
|
||||||
-s --stats Display system package statistics
|
-s --stats Display system package statistics
|
||||||
-w --news Print arch news
|
-w --news Print arch news
|
||||||
|
|
||||||
yay specific options:
|
yay specific options (used with -Y):
|
||||||
-c --clean Remove unneeded dependencies (-cc to ignore optdepends)
|
-c --clean Remove unneeded dependencies (-cc to ignore optdepends)
|
||||||
--gendb Generates development package DB used for updating
|
--gendb Generates development package DB used for updating
|
||||||
|
|
||||||
getpkgbuild specific options:
|
getpkgbuild specific options (used with -G):
|
||||||
-f --force Force download for existing ABS packages
|
-f --force Force download for existing ABS packages
|
||||||
-p --print Print pkgbuild of packages`)
|
-p --print Print pkgbuild of packages`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ func hasParam(arg string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parses short hand options such as:
|
// Parses short hand options such as:
|
||||||
// -Syu -b/some/path -.
|
// -Syu -b /some/path -.
|
||||||
func (a *Arguments) parseShortOption(arg, param string) (usedNext bool, err error) {
|
func (a *Arguments) parseShortOption(arg, param string) (usedNext bool, err error) {
|
||||||
if arg == "-" {
|
if arg == "-" {
|
||||||
err = a.AddArg("-")
|
err = a.AddArg("-")
|
||||||
@@ -655,6 +655,14 @@ func (a *Arguments) Parse() error {
|
|||||||
if len(a.Targets) > 0 {
|
if len(a.Targets) > 0 {
|
||||||
a.Op = "Y"
|
a.Op = "Y"
|
||||||
} else {
|
} else {
|
||||||
|
// Handle args incompatible with -Syu
|
||||||
|
if a.ExistsArg("c", "clean") {
|
||||||
|
fmt.Println(gotext.Get("the clean command requires an operation to be specified"))
|
||||||
|
fmt.Println(gotext.Get("did you mean yay -Scc (clean caches) or yay -Ycc (clean orphaned packages)?"))
|
||||||
|
|
||||||
|
return errors.New(gotext.Get("invalid option"))
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := a.parseShortOption("-Syu", ""); err != nil {
|
if _, err := a.parseShortOption("-Syu", ""); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user