Rework flags to use pflag
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,2 @@
|
|||||||
*.log
|
*.log
|
||||||
.env
|
|
||||||
*.exe
|
*.exe
|
||||||
|
1
go.mod
1
go.mod
@@ -29,6 +29,7 @@ require (
|
|||||||
github.com/pjbgf/sha1cd v0.3.0 // indirect
|
github.com/pjbgf/sha1cd v0.3.0 // indirect
|
||||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
|
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
|
||||||
github.com/skeema/knownhosts v1.2.2 // indirect
|
github.com/skeema/knownhosts v1.2.2 // indirect
|
||||||
|
github.com/spf13/pflag v1.0.10 // indirect
|
||||||
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
github.com/xanzy/ssh-agent v0.3.3 // indirect
|
||||||
golang.org/x/crypto v0.22.0 // indirect
|
golang.org/x/crypto v0.22.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 // indirect
|
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 // indirect
|
||||||
|
2
go.sum
2
go.sum
@@ -81,6 +81,8 @@ github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG
|
|||||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
|
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
|
||||||
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
|
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
|
||||||
|
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||||
|
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
35
main.go
35
main.go
@@ -2,10 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"flag"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
flag "github.com/spf13/pflag"
|
||||||
|
|
||||||
"code.gitea.io/sdk/gitea"
|
"code.gitea.io/sdk/gitea"
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/config"
|
"github.com/go-git/go-git/v5/config"
|
||||||
@@ -14,28 +15,17 @@ import (
|
|||||||
logger "git.site.quack-lab.dev/dave/cylogger"
|
logger "git.site.quack-lab.dev/dave/cylogger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "1.0.0"
|
var Version = "2.0.0"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
name := flag.String("name", "", "Name of the repository")
|
name := flag.StringP("name", "n", "", "Name of the repository")
|
||||||
flag.String("n", "", "Name of the repository")
|
private := flag.BoolP("private", "p", false, "Make the repository private")
|
||||||
|
noinit := flag.BoolP("noinit", "ni", false, "Do not add remote to the new repo")
|
||||||
private := flag.Bool("private", false, "Make the repository private")
|
forceInit := flag.BoolP("force", "f", false, "Force assignment of the remote (deletes existing origin)")
|
||||||
flag.Bool("p", false, "Make the repository private (shorthand)")
|
remote := flag.StringP("remote", "r", "origin", "Name of the remote to create for the new repository")
|
||||||
|
version := flag.BoolP("version", "v", false, "Show version")
|
||||||
noinit := flag.Bool("noinit", false, "Do not add remote to the new repo")
|
dryrun := flag.Bool("dryrun", false, "Dry run")
|
||||||
flag.Bool("ni", false, "Do not add remote to the new repo (shorthand)")
|
help := flag.BoolP("help", "h", false, "Show help")
|
||||||
|
|
||||||
forceInit := flag.Bool("f", false, "Force assignment of the remote (deletes existing origin)")
|
|
||||||
|
|
||||||
remote := flag.String("remote", "origin", "Name of the remote to create for the new repository")
|
|
||||||
flag.String("r", "origin", "Name of the remote to create for the new repository (shorthand)")
|
|
||||||
|
|
||||||
version := flag.Bool("v", false, "Show version")
|
|
||||||
flag.Bool("version", false, "Show version")
|
|
||||||
|
|
||||||
help := flag.Bool("h", false, "Show help")
|
|
||||||
flag.Bool("help", false, "Show help")
|
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
logger.InitFlag()
|
logger.InitFlag()
|
||||||
@@ -92,8 +82,9 @@ func main() {
|
|||||||
logger.Info("Name: %s", *name)
|
logger.Info("Name: %s", *name)
|
||||||
logger.Info("Private: %t", *private)
|
logger.Info("Private: %t", *private)
|
||||||
logger.Info("Noinit: %t", *noinit)
|
logger.Info("Noinit: %t", *noinit)
|
||||||
logger.Info("ForceInit: %t", *forceInit)
|
logger.Info("Force: %t", *forceInit)
|
||||||
logger.Info("Remote: %s", *remote)
|
logger.Info("Remote: %s", *remote)
|
||||||
|
logger.Info("Dryrun: %t", *dryrun)
|
||||||
|
|
||||||
client, err := gitea.NewClient(url)
|
client, err := gitea.NewClient(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user