mirror of
https://github.com/celogeek/piwigo-cli.git
synced 2025-05-25 02:02: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 {
|
||||
List CategoriesListCommand `command:"list" description:"List categories"`
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/url"
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
type ImagesGroup struct {
|
||||
List ImagesListCommand `command:"list" description:"List of images"`
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/celogeek/piwigo-cli/internal/piwigo"
|
@ -1,9 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/celogeek/piwigo-cli/internal/piwigocli"
|
||||
"os"
|
||||
|
||||
"github.com/jessevdk/go-flags"
|
||||
)
|
||||
|
||||
func main() {
|
||||
piwigocli.Run()
|
||||
type Options struct {
|
||||
}
|
||||
|
||||
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 {
|
||||
List MethodListCommand `command:"list" description:"List of available methods"`
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
type SessionGroup struct {
|
||||
Login SessionLoginCommand `command:"login" description:"Initialize a connection to a piwigo instance"`
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package piwigocli
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
@ -14,8 +14,8 @@ type Tree interface {
|
||||
}
|
||||
|
||||
type node struct {
|
||||
Name string
|
||||
children map[string]*node
|
||||
Name string
|
||||
Nodes map[string]*node
|
||||
}
|
||||
|
||||
func NewTree() Tree {
|
||||
@ -25,13 +25,13 @@ func NewTree() Tree {
|
||||
}
|
||||
|
||||
func (t *node) Add(name string) Tree {
|
||||
if t.children == nil {
|
||||
t.children = map[string]*node{}
|
||||
if t.Nodes == nil {
|
||||
t.Nodes = map[string]*node{}
|
||||
}
|
||||
n, ok := t.children[name]
|
||||
n, ok := t.Nodes[name]
|
||||
if !ok {
|
||||
n = &node{Name: name}
|
||||
t.children[name] = n
|
||||
t.Nodes[name] = n
|
||||
}
|
||||
return n
|
||||
}
|
||||
@ -44,9 +44,9 @@ func (t *node) AddPath(path string) Tree {
|
||||
}
|
||||
|
||||
func (t *node) Children() []*node {
|
||||
childs := make([]*node, len(t.children))
|
||||
childs := make([]*node, len(t.Nodes))
|
||||
i := 0
|
||||
for _, n := range t.children {
|
||||
for _, n := range t.Nodes {
|
||||
childs[i] = n
|
||||
i++
|
||||
}
|
||||
@ -57,7 +57,7 @@ func (t *node) Children() []*node {
|
||||
}
|
||||
|
||||
func (t *node) HasChildren() bool {
|
||||
return t.children != nil
|
||||
return t.Nodes != nil
|
||||
}
|
||||
|
||||
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