mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 10:12:37 +02:00
36 lines
719 B
Go
36 lines
719 B
Go
package piwigocli
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
|
)
|
|
|
|
type MethodTryCommand struct {
|
|
MethodName string `short:"m" long:"method-name" description:"Method name to test"`
|
|
MethodParams url.Values `short:"p" long:"params" description:"Parameter for the method" env-delim:","`
|
|
}
|
|
|
|
func (c *MethodTryCommand) Execute(args []string) error {
|
|
p := piwigo.Piwigo{}
|
|
if err := p.LoadConfig(); err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err := p.Login()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var result map[string]interface{}
|
|
|
|
if err := p.Post(c.MethodName, &c.MethodParams, &result); err != nil {
|
|
return err
|
|
}
|
|
|
|
piwigo.DumpResponse(result)
|
|
piwigo.DumpResponse(c.MethodParams)
|
|
|
|
return nil
|
|
}
|