mirror of
https://github.com/Jguer/yay.git
synced 2025-12-27 07:35:48 -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
|
||||
keepCurrent := false
|
||||
|
||||
_, removeAll, _ := cmdArgs.GetArg("c", "clean")
|
||||
removeAll := cmdArgs.ExistsArg("c", "clean")
|
||||
|
||||
for _, v := range run.PacmanConf.CleanMethod {
|
||||
switch v {
|
||||
|
||||
8
cmd.go
8
cmd.go
@@ -51,7 +51,7 @@ New operations:
|
||||
yay {-Y --yay} [options] [package(s)]
|
||||
|
||||
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:
|
||||
-N --repo Assume targets are from the repositories
|
||||
@@ -122,18 +122,18 @@ Permanent configuration options:
|
||||
|
||||
--timeupdate Check packages' AUR page for changes during sysupgrade
|
||||
|
||||
show specific options:
|
||||
show specific options (used with -P):
|
||||
-c --complete Used for completions
|
||||
-d --defaultconfig Print default yay configuration
|
||||
-g --currentconfig Print current yay configuration
|
||||
-s --stats Display system package statistics
|
||||
-w --news Print arch news
|
||||
|
||||
yay specific options:
|
||||
yay specific options (used with -Y):
|
||||
-c --clean Remove unneeded dependencies (-cc to ignore optdepends)
|
||||
--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
|
||||
-p --print Print pkgbuild of packages`)
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ func hasParam(arg string) bool {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
if arg == "-" {
|
||||
err = a.AddArg("-")
|
||||
@@ -655,6 +655,14 @@ func (a *Arguments) Parse() error {
|
||||
if len(a.Targets) > 0 {
|
||||
a.Op = "Y"
|
||||
} 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 {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user