mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 02:02:37 +02:00
improve format
This commit is contained in:
parent
8a4002c3b2
commit
931bd470a5
2
go.mod
2
go.mod
@ -3,6 +3,8 @@ module github.com/celogeek/piwigo-cli
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/jedib0t/go-pretty/v6 v6.2.4 // indirect
|
||||
github.com/jessevdk/go-flags v1.5.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect
|
||||
)
|
||||
|
10
go.sum
10
go.sum
@ -1,4 +1,14 @@
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E=
|
||||
github.com/jedib0t/go-pretty/v6 v6.2.4 h1:wdaj2KHD2W+mz8JgJ/Q6L/T5dB7kyqEFI16eLq7GEmk=
|
||||
github.com/jedib0t/go-pretty/v6 v6.2.4/go.mod h1:+nE9fyyHGil+PuISTCrp7avEdo6bqoMwqZnuiK2r2a0=
|
||||
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
|
||||
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -28,7 +28,12 @@ func (p *Piwigo) Post(method string, form *url.Values, resp interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", Url, strings.NewReader(form.Encode()))
|
||||
var encodedForm string
|
||||
if form != nil {
|
||||
encodedForm = form.Encode()
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", Url, strings.NewReader(encodedForm))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package piwigocli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
)
|
||||
|
||||
type StatusCommand struct {
|
||||
@ -17,8 +17,6 @@ type StatusResponse struct {
|
||||
}
|
||||
|
||||
func (c *StatusCommand) Execute(args []string) error {
|
||||
fmt.Println("Status:")
|
||||
|
||||
Piwigo := piwigo.Piwigo{}
|
||||
if err := Piwigo.LoadConfig(); err != nil {
|
||||
return err
|
||||
@ -26,11 +24,22 @@ func (c *StatusCommand) Execute(args []string) error {
|
||||
|
||||
resp := &StatusResponse{}
|
||||
|
||||
if err := Piwigo.Post("pwg.session.getStatus", &url.Values{}, &resp); err != nil {
|
||||
if err := Piwigo.Post("pwg.session.getStatus", nil, &resp); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf(" Version: %s\n", resp.Version)
|
||||
fmt.Printf(" User : %s\n", resp.User)
|
||||
fmt.Printf(" Role : %s\n", resp.Role)
|
||||
|
||||
t := table.NewWriter()
|
||||
|
||||
t.AppendHeader(table.Row{"", "Value"})
|
||||
t.AppendRows([]table.Row{
|
||||
{"Version", resp.Version},
|
||||
{"User", resp.User},
|
||||
{"Role", resp.Role},
|
||||
})
|
||||
|
||||
t.SetOutputMirror(os.Stdout)
|
||||
t.SetStyle(table.StyleLight)
|
||||
t.Render()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user