mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 10:12:37 +02:00
filter method list
This commit is contained in:
parent
9f3d9a0f0c
commit
91c2e5b85a
@ -37,13 +37,13 @@ func (c *CategoriesListCommand) Execute(args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
t := table.NewWriter()
|
||||
|
||||
t.AppendHeader(table.Row{"Id", "Name", "Images", "Url"})
|
||||
filter := regexp.MustCompile("")
|
||||
if c.Filter != "" {
|
||||
filter = regexp.MustCompile("(?i)" + c.Filter)
|
||||
}
|
||||
|
||||
t := table.NewWriter()
|
||||
t.AppendHeader(table.Row{"Id", "Name", "Images", "Url"})
|
||||
for _, category := range resp.Categories {
|
||||
if filter.MatchString(category.Name) {
|
||||
t.AppendRow(table.Row{
|
||||
|
@ -2,12 +2,15 @@ package piwigocli
|
||||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
)
|
||||
|
||||
type MethodListCommand struct{}
|
||||
type MethodListCommand struct {
|
||||
Filter string `short:"x" long:"filter" description:"Regexp filter"`
|
||||
}
|
||||
|
||||
type MethodListResult struct {
|
||||
Methods piwigo.Methods `json:"methods"`
|
||||
@ -30,14 +33,20 @@ func (c *MethodListCommand) Execute(args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
t := table.NewWriter()
|
||||
filter := regexp.MustCompile("")
|
||||
if c.Filter != "" {
|
||||
filter = regexp.MustCompile("(?i)" + c.Filter)
|
||||
}
|
||||
|
||||
t := table.NewWriter()
|
||||
t.AppendHeader(table.Row{"Methods"})
|
||||
for _, method := range result.Methods {
|
||||
if filter.MatchString(method) {
|
||||
t.AppendRow(table.Row{
|
||||
method,
|
||||
})
|
||||
}
|
||||
}
|
||||
t.SetOutputMirror(os.Stdout)
|
||||
t.SetStyle(table.StyleLight)
|
||||
t.Render()
|
||||
|
Loading…
x
Reference in New Issue
Block a user