From 92153508b3d8e43fc152eb2612ccf3abb694c90f Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Sat, 17 Sep 2022 18:16:30 -0400 Subject: [PATCH] Initial Go project structure --- .gitignore | 3 +++ .woodpecker.yml | 31 +++++++++++++++++++++++++++++++ LICENSE | 2 +- README.md | 19 +++++++++++++++++-- cmd/root.go | 25 +++++++++++++++++++++++++ go.mod | 9 +++++++++ go.sum | 10 ++++++++++ mcst.go | 9 +++++++++ 8 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 .woodpecker.yml create mode 100644 cmd/root.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 mcst.go diff --git a/.gitignore b/.gitignore index adf8f72..a9189e5 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ # Go workspace file go.work +# Compiled Go binary +mcst + diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..2a60b3b --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,31 @@ +pipeline: + build_test: + image: golang:1.16 + commands: + - go build + + test: + image: golang:1.16 + commands: + - go test -v ./... + + build_release: + image: golang:1.16 + commands: + - go mod vendor + - GOOS=linux GOARCH=amd64 go build -ldflags "-X git.metaunix.net/BitGoblin/mcst/cmd.version=${CI_COMMIT_TAG}" -o "dist/mcst-linux-amd64-${CI_COMMIT_TAG}" + - GOOS=windows GOARCH=amd64 go build -ldflags "-X git.metaunix.net/BitGoblin/mcst/cmd.version=${CI_COMMIT_TAG}" -o "dist/mcst-windows-amd64-${CI_COMMIT_TAG}.exe" + when: + event: tag + + gitea_release: + image: plugins/gitea-release + settings: + api_key: + from_secret: gitea_api_key + base_url: https://git.metaunix.net + title: "${CI_COMMIT_TAG}" + files: + - dist/mcst-* + when: + event: tag diff --git a/LICENSE b/LICENSE index 5f662b3..2b5518f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) +Copyright (c) 2022 Bit Goblin Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index ea52531..95bbe86 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,18 @@ -# mcst +# MCST -Bit Goblin minecraft server tool \ No newline at end of file +Bit Goblin minecraft server management tool + +## Installation + +Build dependencies: +* go +* make + +To install dependencies on Ubuntu: `apt install golang make` +To install dependencies on Red Hat/AlmaLinux: `dnf install go make` + +To install MCST as a system utility: `make build && sudo make install` + +## Uninstallation + +To uninstall MCST (if it was installed through make): `sudo make uninstall` diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..74bf5a2 --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,25 @@ +package cmd + +import ( + "log" + "os" + + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "mcst", + Short: "MCST is a tool to manage Minecraft Java edition servers.", + Long: `A flexible yet user-friendly tool to manage Minecraft Java edition server. + Source code available at https://git.metaunix.net/BitGoblin/mcst`, + Run: func(cmd *cobra.Command, args []string) { + log.Printf("This is a test.") + }, +} + +func Start() { + if err := rootCmd.Execute(); err != nil { + log.Println(err) + os.Exit(1) + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..653b415 --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module git.metaunix.net/BitGoblin/mcst + +go 1.18 + +require ( + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/spf13/cobra v1.5.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..0d85248 --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= +github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/mcst.go b/mcst.go new file mode 100644 index 0000000..35910a5 --- /dev/null +++ b/mcst.go @@ -0,0 +1,9 @@ +package main + +import ( + "git.metaunix.net/BitGoblin/mcst/cmd" +) + +func main() { + cmd.Start() +}