mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53:48 +03:00
main: remove redundant equal function
This commit is contained in:
parent
08995c7806
commit
0e5e16b3d0
1 changed files with 3 additions and 14 deletions
17
main.go
17
main.go
|
@ -31,6 +31,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
"github.com/mjl-/adns"
|
"github.com/mjl-/adns"
|
||||||
|
|
||||||
|
@ -280,28 +281,16 @@ If a single command matches, its usage and full help text is printed.
|
||||||
c.Usage()
|
c.Usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
equal := func(a, b []string) bool {
|
|
||||||
if len(a) != len(b) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for i := range a {
|
|
||||||
if a[i] != b[i] {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
prefix := func(l, pre []string) bool {
|
prefix := func(l, pre []string) bool {
|
||||||
if len(pre) > len(l) {
|
if len(pre) > len(l) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return equal(pre, l[:len(pre)])
|
return slices.Equal(pre, l[:len(pre)])
|
||||||
}
|
}
|
||||||
|
|
||||||
var partial []cmd
|
var partial []cmd
|
||||||
for _, c := range cmds {
|
for _, c := range cmds {
|
||||||
if equal(c.words, args) {
|
if slices.Equal(c.words, args) {
|
||||||
c.gather()
|
c.gather()
|
||||||
fmt.Print(c.makeUsage())
|
fmt.Print(c.makeUsage())
|
||||||
if c.help != "" {
|
if c.help != "" {
|
||||||
|
|
Loading…
Reference in a new issue