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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
t := table.NewWriter()
|
|
||||||
|
|
||||||
t.AppendHeader(table.Row{"Id", "Name", "Images", "Url"})
|
|
||||||
filter := regexp.MustCompile("")
|
filter := regexp.MustCompile("")
|
||||||
if c.Filter != "" {
|
if c.Filter != "" {
|
||||||
filter = regexp.MustCompile("(?i)" + c.Filter)
|
filter = regexp.MustCompile("(?i)" + c.Filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t := table.NewWriter()
|
||||||
|
t.AppendHeader(table.Row{"Id", "Name", "Images", "Url"})
|
||||||
for _, category := range resp.Categories {
|
for _, category := range resp.Categories {
|
||||||
if filter.MatchString(category.Name) {
|
if filter.MatchString(category.Name) {
|
||||||
t.AppendRow(table.Row{
|
t.AppendRow(table.Row{
|
||||||
|
@ -2,12 +2,15 @@ package piwigocli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
||||||
"github.com/jedib0t/go-pretty/v6/table"
|
"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 {
|
type MethodListResult struct {
|
||||||
Methods piwigo.Methods `json:"methods"`
|
Methods piwigo.Methods `json:"methods"`
|
||||||
@ -30,13 +33,19 @@ func (c *MethodListCommand) Execute(args []string) error {
|
|||||||
return err
|
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"})
|
t.AppendHeader(table.Row{"Methods"})
|
||||||
for _, method := range result.Methods {
|
for _, method := range result.Methods {
|
||||||
t.AppendRow(table.Row{
|
if filter.MatchString(method) {
|
||||||
method,
|
t.AppendRow(table.Row{
|
||||||
})
|
method,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
t.SetOutputMirror(os.Stdout)
|
t.SetOutputMirror(os.Stdout)
|
||||||
t.SetStyle(table.StyleLight)
|
t.SetStyle(table.StyleLight)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user