mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 18:22:37 +02:00
rename reflexion method
This commit is contained in:
parent
ff4f5e99f9
commit
2889e94dd9
12
internal/piwigocli/method.go
Normal file
12
internal/piwigocli/method.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package piwigocli
|
||||||
|
|
||||||
|
type MethodGroup struct {
|
||||||
|
List MethodListCommand `command:"list" description:"List of available methods"`
|
||||||
|
Details MethodDetailsCommand `command:"details" description:"Details of a method"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var methodGroup MethodGroup
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
parser.AddCommand("method", "Reflexion management", "", &methodGroup)
|
||||||
|
}
|
@ -11,11 +11,11 @@ import (
|
|||||||
"github.com/jedib0t/go-pretty/v6/table"
|
"github.com/jedib0t/go-pretty/v6/table"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReflexionMethodDetailsCommand struct {
|
type MethodDetailsCommand struct {
|
||||||
MethodName string `short:"m" long:"method-name" description:"Method name to details"`
|
MethodName string `short:"m" long:"method-name" description:"Method name to details"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReflexionMethodDetailsParams struct {
|
type MethodDetailsParams struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Optional bool `json:"optional"`
|
Optional bool `json:"optional"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
@ -25,19 +25,19 @@ type ReflexionMethodDetailsParams struct {
|
|||||||
Info string `json:"info"`
|
Info string `json:"info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReflexionMethodDetailsOptions struct {
|
type MethodDetailsOptions struct {
|
||||||
Admin bool `json:"admin_only"`
|
Admin bool `json:"admin_only"`
|
||||||
PostOnly bool `json:"post_only"`
|
PostOnly bool `json:"post_only"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReflexionMethodDetailsResult struct {
|
type MethodDetailsResult struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Options ReflexionMethodDetailsOptions `json:"options"`
|
Options MethodDetailsOptions `json:"options"`
|
||||||
Parameters []ReflexionMethodDetailsParams `json:"params"`
|
Parameters []MethodDetailsParams `json:"params"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *ReflexionMethodDetailsOptions) UnmarshalJSON(data []byte) error {
|
func (j *MethodDetailsOptions) UnmarshalJSON(data []byte) error {
|
||||||
var r interface{}
|
var r interface{}
|
||||||
if err := json.Unmarshal(data, &r); err != nil {
|
if err := json.Unmarshal(data, &r); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -51,7 +51,7 @@ func (j *ReflexionMethodDetailsOptions) UnmarshalJSON(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ReflexionMethodDetailsCommand) Execute(args []string) error {
|
func (c *MethodDetailsCommand) Execute(args []string) error {
|
||||||
p := piwigo.Piwigo{}
|
p := piwigo.Piwigo{}
|
||||||
if err := p.LoadConfig(); err != nil {
|
if err := p.LoadConfig(); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -62,7 +62,7 @@ func (c *ReflexionMethodDetailsCommand) Execute(args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var result ReflexionMethodDetailsResult
|
var result MethodDetailsResult
|
||||||
|
|
||||||
if err := p.Post("reflection.getMethodDetails", &url.Values{
|
if err := p.Post("reflection.getMethodDetails", &url.Values{
|
||||||
"methodName": []string{c.MethodName},
|
"methodName": []string{c.MethodName},
|
@ -7,13 +7,13 @@ import (
|
|||||||
"github.com/jedib0t/go-pretty/v6/table"
|
"github.com/jedib0t/go-pretty/v6/table"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReflexionMethodListCommand struct{}
|
type MethodListCommand struct{}
|
||||||
|
|
||||||
type ReflexionMethodListResult struct {
|
type MethodListResult struct {
|
||||||
Methods []string `json:"methods"`
|
Methods []string `json:"methods"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ReflexionMethodListCommand) Execute(args []string) error {
|
func (c *MethodListCommand) Execute(args []string) error {
|
||||||
p := piwigo.Piwigo{}
|
p := piwigo.Piwigo{}
|
||||||
if err := p.LoadConfig(); err != nil {
|
if err := p.LoadConfig(); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -24,7 +24,7 @@ func (c *ReflexionMethodListCommand) Execute(args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var result ReflexionMethodListResult
|
var result MethodListResult
|
||||||
|
|
||||||
if err := p.Post("reflection.getMethodList", nil, &result); err != nil {
|
if err := p.Post("reflection.getMethodList", nil, &result); err != nil {
|
||||||
return err
|
return err
|
@ -1,12 +0,0 @@
|
|||||||
package piwigocli
|
|
||||||
|
|
||||||
type ReflexionGroup struct {
|
|
||||||
MethodList ReflexionMethodListCommand `command:"method-list" description:"List of available methods"`
|
|
||||||
MethodDetails ReflexionMethodDetailsCommand `command:"method-details" description:"Details of a method"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var reflexionGroup ReflexionGroup
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
parser.AddCommand("reflexion", "Reflexion management", "", &reflexionGroup)
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user