From 2889e94dd99ff7a4e4dd5cb3aa95831ced4d8c8e Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Sat, 18 Dec 2021 22:57:46 +0100 Subject: [PATCH] rename reflexion method --- internal/piwigocli/method.go | 12 ++++++++++ ...on_method_details.go => method_details.go} | 22 +++++++++---------- ...eflexion_method_list.go => method_list.go} | 8 +++---- internal/piwigocli/reflexion.go | 12 ---------- 4 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 internal/piwigocli/method.go rename internal/piwigocli/{reflexion_method_details.go => method_details.go} (78%) rename internal/piwigocli/{reflexion_method_list.go => method_list.go} (77%) delete mode 100644 internal/piwigocli/reflexion.go diff --git a/internal/piwigocli/method.go b/internal/piwigocli/method.go new file mode 100644 index 0000000..be1ff1b --- /dev/null +++ b/internal/piwigocli/method.go @@ -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) +} diff --git a/internal/piwigocli/reflexion_method_details.go b/internal/piwigocli/method_details.go similarity index 78% rename from internal/piwigocli/reflexion_method_details.go rename to internal/piwigocli/method_details.go index fc5176a..8679e41 100644 --- a/internal/piwigocli/reflexion_method_details.go +++ b/internal/piwigocli/method_details.go @@ -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}, diff --git a/internal/piwigocli/reflexion_method_list.go b/internal/piwigocli/method_list.go similarity index 77% rename from internal/piwigocli/reflexion_method_list.go rename to internal/piwigocli/method_list.go index 36d733a..81a5985 100644 --- a/internal/piwigocli/reflexion_method_list.go +++ b/internal/piwigocli/method_list.go @@ -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 diff --git a/internal/piwigocli/reflexion.go b/internal/piwigocli/reflexion.go deleted file mode 100644 index fb49cbf..0000000 --- a/internal/piwigocli/reflexion.go +++ /dev/null @@ -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) -}