mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 18:22:37 +02:00
move piwigocli from internal to cmd
This commit is contained in:
parent
84b9445e1d
commit
653bf3ffdd
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
type CategoriesGroup struct {
|
type CategoriesGroup struct {
|
||||||
List CategoriesListCommand `command:"list" description:"List categories"`
|
List CategoriesListCommand `command:"list" description:"List categories"`
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
type ImagesGroup struct {
|
type ImagesGroup struct {
|
||||||
List ImagesListCommand `command:"list" description:"List of images"`
|
List ImagesListCommand `command:"list" description:"List of images"`
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
@ -1,9 +1,28 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/celogeek/piwigo-cli/internal/piwigocli"
|
"os"
|
||||||
|
|
||||||
|
"github.com/jessevdk/go-flags"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
type Options struct {
|
||||||
piwigocli.Run()
|
}
|
||||||
|
|
||||||
|
var options Options
|
||||||
|
|
||||||
|
var parser = flags.NewParser(&options, flags.Default)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if _, err := parser.Parse(); err != nil {
|
||||||
|
switch flagsErr := err.(type) {
|
||||||
|
case flags.ErrorType:
|
||||||
|
if flagsErr == flags.ErrHelp {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
os.Exit(1)
|
||||||
|
default:
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
type MethodGroup struct {
|
type MethodGroup struct {
|
||||||
List MethodListCommand `command:"list" description:"List of available methods"`
|
List MethodListCommand `command:"list" description:"List of available methods"`
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
type SessionGroup struct {
|
type SessionGroup struct {
|
||||||
Login SessionLoginCommand `command:"login" description:"Initialize a connection to a piwigo instance"`
|
Login SessionLoginCommand `command:"login" description:"Initialize a connection to a piwigo instance"`
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package piwigocli
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
@ -14,8 +14,8 @@ type Tree interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type node struct {
|
type node struct {
|
||||||
Name string
|
Name string
|
||||||
children map[string]*node
|
Nodes map[string]*node
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTree() Tree {
|
func NewTree() Tree {
|
||||||
@ -25,13 +25,13 @@ func NewTree() Tree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *node) Add(name string) Tree {
|
func (t *node) Add(name string) Tree {
|
||||||
if t.children == nil {
|
if t.Nodes == nil {
|
||||||
t.children = map[string]*node{}
|
t.Nodes = map[string]*node{}
|
||||||
}
|
}
|
||||||
n, ok := t.children[name]
|
n, ok := t.Nodes[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
n = &node{Name: name}
|
n = &node{Name: name}
|
||||||
t.children[name] = n
|
t.Nodes[name] = n
|
||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
@ -44,9 +44,9 @@ func (t *node) AddPath(path string) Tree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *node) Children() []*node {
|
func (t *node) Children() []*node {
|
||||||
childs := make([]*node, len(t.children))
|
childs := make([]*node, len(t.Nodes))
|
||||||
i := 0
|
i := 0
|
||||||
for _, n := range t.children {
|
for _, n := range t.Nodes {
|
||||||
childs[i] = n
|
childs[i] = n
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ func (t *node) Children() []*node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *node) HasChildren() bool {
|
func (t *node) HasChildren() bool {
|
||||||
return t.children != nil
|
return t.Nodes != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *node) FlatView() (out chan string) {
|
func (t *node) FlatView() (out chan string) {
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
package piwigocli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/jessevdk/go-flags"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Options struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
var options Options
|
|
||||||
|
|
||||||
var parser = flags.NewParser(&options, flags.Default)
|
|
||||||
|
|
||||||
func Run() {
|
|
||||||
if _, err := parser.Parse(); err != nil {
|
|
||||||
switch flagsErr := err.(type) {
|
|
||||||
case flags.ErrorType:
|
|
||||||
if flagsErr == flags.ErrHelp {
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
os.Exit(1)
|
|
||||||
default:
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user