From 0760013027e54cd738589d7f1c8eeb5ef76233ff Mon Sep 17 00:00:00 2001 From: Jaap de Haan <261428+jdehaan@users.noreply.github.com> Date: Wed, 12 Nov 2025 20:05:56 +0100 Subject: [PATCH 1/3] feat: Create go.yml --- .github/workflows/go.yml | 28 ++++++++++++++++++++++++++++ Makefile | 16 ++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/go.yml create mode 100644 Makefile diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..63f3f50 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,28 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.24' + + - name: Build + run: make build + + - name: Test + run: make test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ca548aa --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +# Makefile to build the project and place the binary in the dist/ directory + +.PHONY: build clean deps test + +deps: + go mod tidy + +build: deps + @mkdir -p dist + go build -o dist/backup ./backup/main.go + +test: + go test ./... -v + +clean: + rm -rf dist \ No newline at end of file From 61b757cabef946c9acb301a23fa90b2a8d8570df Mon Sep 17 00:00:00 2001 From: Jaap de Haan <261428+jdehaan@users.noreply.github.com> Date: Wed, 12 Nov 2025 19:32:40 +0000 Subject: [PATCH 2/3] feat: First draft skeleton for application --- .gitignore | 3 ++- backup/cmd/backup.go | 19 +++++++++++++++++++ backup/cmd/config.go | 19 +++++++++++++++++++ backup/cmd/root.go | 21 +++++++++++++++++++++ backup/cmd/root_test.go | 9 +++++++++ backup/main.go | 9 +++++++++ go.mod | 10 ++++++++++ go.sum | 10 ++++++++++ 8 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 backup/cmd/backup.go create mode 100644 backup/cmd/config.go create mode 100644 backup/cmd/root.go create mode 100644 backup/cmd/root_test.go create mode 100644 backup/main.go create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore index 549c601..ebfba0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +BACKLOG/ logs/ -backup *.log +dist/backup diff --git a/backup/cmd/backup.go b/backup/cmd/backup.go new file mode 100644 index 0000000..126f0f5 --- /dev/null +++ b/backup/cmd/backup.go @@ -0,0 +1,19 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +// backupCmd represents the backup command +var backupCmd = &cobra.Command{ + Use: "backup", + Short: "Perform backup operations", + Long: `The backup subcommand allows you to perform backup operations.`, + Run: func(cmd *cobra.Command, args []string) { + // TODO: Implement backup logic + }, +} + +func init() { + RootCmd.AddCommand(backupCmd) +} diff --git a/backup/cmd/config.go b/backup/cmd/config.go new file mode 100644 index 0000000..28e0097 --- /dev/null +++ b/backup/cmd/config.go @@ -0,0 +1,19 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +// configCmd represents the config command +var configCmd = &cobra.Command{ + Use: "config", + Short: "Manage configuration settings", + Long: `The config subcommand allows you to manage configuration settings.`, + Run: func(cmd *cobra.Command, args []string) { + // TODO: Implement config logic + }, +} + +func init() { + RootCmd.AddCommand(configCmd) +} diff --git a/backup/cmd/root.go b/backup/cmd/root.go new file mode 100644 index 0000000..4d119fd --- /dev/null +++ b/backup/cmd/root.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "os" + + "github.com/spf13/cobra" +) + +// RootCmd represents the base command when called without any subcommands +var RootCmd = &cobra.Command{ + Use: "backup-tool", + Short: "A tool for managing backups", + Long: `backup-tool is a CLI tool for managing backups and configurations.`, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +func Execute() { + if err := RootCmd.Execute(); err != nil { + os.Exit(1) + } +} diff --git a/backup/cmd/root_test.go b/backup/cmd/root_test.go new file mode 100644 index 0000000..f105c44 --- /dev/null +++ b/backup/cmd/root_test.go @@ -0,0 +1,9 @@ +package cmd + +import ( + "testing" +) + +func TestExecute(t *testing.T) { + // TODO: Add tests for the Execute function +} diff --git a/backup/main.go b/backup/main.go new file mode 100644 index 0000000..18c8937 --- /dev/null +++ b/backup/main.go @@ -0,0 +1,9 @@ +package main + +import ( + "backup-rsync/backup/cmd" +) + +func main() { + cmd.Execute() +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..3ef4b66 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module backup-rsync + +go 1.24.9 + +require github.com/spf13/cobra v1.10.1 + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/pflag v1.0.9 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e613680 --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= +github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From ab7930fc94232f906fd2b57c14e13fb402502b88 Mon Sep 17 00:00:00 2001 From: Jaap de Haan <261428+jdehaan@users.noreply.github.com> Date: Wed, 12 Nov 2025 19:41:09 +0000 Subject: [PATCH 3/3] feat: Improve DX --- .devcontainer/devcontainer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ef2c15c..8f6879e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,5 +3,12 @@ "image": "mcr.microsoft.com/devcontainers/go:2-1.24-bookworm", "features": { "ghcr.io/guiyomh/features/golangci-lint:0": {} + }, + "customizations": { + "vscode": { + "extensions": [ + "eamodio.gitlens" + ] + } } }