mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 10:12: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"
|
||||
)
|
||||
|
||||
type ReflexionMethodDetailsCommand struct {
|
||||
type MethodDetailsCommand struct {
|
||||
MethodName string `short:"m" long:"method-name" description:"Method name to details"`
|
||||
}
|
||||
|
||||
type ReflexionMethodDetailsParams struct {
|
||||
type MethodDetailsParams struct {
|
||||
Name string `json:"name"`
|
||||
Optional bool `json:"optional"`
|
||||
Type string `json:"type"`
|
||||
@ -25,19 +25,19 @@ type ReflexionMethodDetailsParams struct {
|
||||
Info string `json:"info"`
|
||||
}
|
||||
|
||||
type ReflexionMethodDetailsOptions struct {
|
||||
type MethodDetailsOptions struct {
|
||||
Admin bool `json:"admin_only"`
|
||||
PostOnly bool `json:"post_only"`
|
||||
}
|
||||
|
||||
type ReflexionMethodDetailsResult struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Options ReflexionMethodDetailsOptions `json:"options"`
|
||||
Parameters []ReflexionMethodDetailsParams `json:"params"`
|
||||
type MethodDetailsResult struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Options MethodDetailsOptions `json:"options"`
|
||||
Parameters []MethodDetailsParams `json:"params"`
|
||||
}
|
||||
|
||||
func (j *ReflexionMethodDetailsOptions) UnmarshalJSON(data []byte) error {
|
||||
func (j *MethodDetailsOptions) UnmarshalJSON(data []byte) error {
|
||||
var r interface{}
|
||||
if err := json.Unmarshal(data, &r); err != nil {
|
||||
return err
|
||||
@ -51,7 +51,7 @@ func (j *ReflexionMethodDetailsOptions) UnmarshalJSON(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ReflexionMethodDetailsCommand) Execute(args []string) error {
|
||||
func (c *MethodDetailsCommand) Execute(args []string) error {
|
||||
p := piwigo.Piwigo{}
|
||||
if err := p.LoadConfig(); err != nil {
|
||||
return err
|
||||
@ -62,7 +62,7 @@ func (c *ReflexionMethodDetailsCommand) Execute(args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
var result ReflexionMethodDetailsResult
|
||||
var result MethodDetailsResult
|
||||
|
||||
if err := p.Post("reflection.getMethodDetails", &url.Values{
|
||||
"methodName": []string{c.MethodName},
|
@ -7,13 +7,13 @@ import (
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
)
|
||||
|
||||
type ReflexionMethodListCommand struct{}
|
||||
type MethodListCommand struct{}
|
||||
|
||||
type ReflexionMethodListResult struct {
|
||||
type MethodListResult struct {
|
||||
Methods []string `json:"methods"`
|
||||
}
|
||||
|
||||
func (c *ReflexionMethodListCommand) Execute(args []string) error {
|
||||
func (c *MethodListCommand) Execute(args []string) error {
|
||||
p := piwigo.Piwigo{}
|
||||
if err := p.LoadConfig(); err != nil {
|
||||
return err
|
||||
@ -24,7 +24,7 @@ func (c *ReflexionMethodListCommand) Execute(args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
var result ReflexionMethodListResult
|
||||
var result MethodListResult
|
||||
|
||||
if err := p.Post("reflection.getMethodList", nil, &result); err != nil {
|
||||
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