move piwigocli from internal to cmd

This commit is contained in:
Celogeek 2021-12-31 11:46:38 +01:00
parent 84b9445e1d
commit 653bf3ffdd
Signed by: celogeek
GPG Key ID: E6B7BDCFC446233A
18 changed files with 46 additions and 55 deletions

View File

@ -1,4 +1,4 @@
package piwigocli
package main
type CategoriesGroup struct {
List CategoriesListCommand `command:"list" description:"List categories"`

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"os"

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"net/url"

View File

@ -1,4 +1,4 @@
package piwigocli
package main
type ImagesGroup struct {
List ImagesListCommand `command:"list" description:"List of images"`

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"fmt"

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"fmt"

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"errors"

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"github.com/celogeek/piwigo-cli/internal/piwigo"

View File

@ -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)
}
}
}

View File

@ -1,4 +1,4 @@
package piwigocli
package main
type MethodGroup struct {
List MethodListCommand `command:"list" description:"List of available methods"`

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"fmt"

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"encoding/json"

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"errors"

View File

@ -1,4 +1,4 @@
package piwigocli
package main
type SessionGroup struct {
Login SessionLoginCommand `command:"login" description:"Initialize a connection to a piwigo instance"`

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"fmt"

View File

@ -1,4 +1,4 @@
package piwigocli
package main
import (
"os"

View File

@ -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) {

View File

@ -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)
}
}
}