mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 18:22:37 +02:00
33 lines
669 B
Go
33 lines
669 B
Go
package piwigocli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
|
)
|
|
|
|
type SessionLoginCommand struct {
|
|
Url string `short:"u" long:"url" description:"Url of the instance" required:"true"`
|
|
Login string `short:"l" long:"login" description:"Login" required:"true"`
|
|
Password string `short:"p" long:"password" description:"Password" required:"true"`
|
|
}
|
|
|
|
func (c *SessionLoginCommand) Execute(args []string) error {
|
|
fmt.Printf("Login on %s...\n", c.Url)
|
|
|
|
p := piwigo.Piwigo{
|
|
Url: c.Url,
|
|
Username: c.Login,
|
|
Password: c.Password,
|
|
}
|
|
|
|
_, err := p.Login()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println("Login succeed!")
|
|
|
|
return nil
|
|
}
|