From 6cadda01a851c00bf55c4e898449a4cb6fff726c Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Mon, 23 Mar 2026 21:19:37 -0700 Subject: [PATCH] Step 1: Replace C++ prototype with Go project scaffolding. Remove all old C++ source files, proto definitions, CMake build, clang configs, IDE files, and Trunk linter config. Initialize Go module (github.com/kisom/sgard) with cobra and yaml.v3 deps. Set up cobra root command with --repo persistent flag. Co-Authored-By: Claude Opus 4.6 (1M context) --- .clang-format | 67 ---------------------- .clang-tidy | 31 ---------- .gitignore | 6 +- .idea/.gitignore | 8 --- .idea/misc.xml | 4 -- .idea/modules.xml | 8 --- .idea/sgard.iml | 2 - .idea/vcs.xml | 6 -- .trunk/.gitignore | 8 --- .trunk/configs/.shellcheckrc | 7 --- .trunk/configs/.yamllint.yaml | 10 ---- .trunk/trunk.yaml | 34 ----------- CMakeLists.txt | 38 ------------- PROGRESS.md | 13 +++-- PROJECT_PLAN.md | 14 ++--- cmd/sgard/main.go | 33 +++++++++++ go.mod | 10 ++++ go.sum | 12 ++++ proto/header.proto | 12 ---- proto/homedir.proto | 12 ---- proto/path.proto | 33 ----------- scripts/install-depdendencies.sh | 98 -------------------------------- sgard.cc | 25 -------- 23 files changed, 71 insertions(+), 420 deletions(-) delete mode 100644 .clang-format delete mode 100644 .clang-tidy delete mode 100644 .idea/.gitignore delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/sgard.iml delete mode 100644 .idea/vcs.xml delete mode 100644 .trunk/.gitignore delete mode 100644 .trunk/configs/.shellcheckrc delete mode 100644 .trunk/configs/.yamllint.yaml delete mode 100644 .trunk/trunk.yaml delete mode 100644 CMakeLists.txt create mode 100644 cmd/sgard/main.go create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 proto/header.proto delete mode 100644 proto/homedir.proto delete mode 100644 proto/path.proto delete mode 100755 scripts/install-depdendencies.sh delete mode 100644 sgard.cc diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 0451da0..0000000 --- a/.clang-format +++ /dev/null @@ -1,67 +0,0 @@ -# Generated from CLion C/C++ Code Style settings -BasedOnStyle: LLVM -AccessModifierOffset: -8 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: Consecutive -AlignOperands: Align -AllowAllArgumentsOnNextLine: false -AllowAllConstructorInitializersOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: Always -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: Always -AllowShortLambdasOnASingleLine: All -AllowShortLoopsOnASingleLine: true -AlwaysBreakAfterReturnType: TopLevel -AlwaysBreakTemplateDeclarations: Yes -BreakBeforeBraces: Custom -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: Never - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: true -BreakBeforeBinaryOperators: None -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: BeforeColon -BreakInheritanceList: BeforeColon -ColumnLimit: 0 -CompactNamespaces: false -ContinuationIndentWidth: 4 -IndentCaseLabels: false -IndentPPDirectives: None -IndentWidth: 8 -KeepEmptyLinesAtTheStartOfBlocks: true -MaxEmptyLinesToKeep: 2 -NamespaceIndentation: None -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -QualifierAlignment: Left -PointerAlignment: Right -ReflowComments: false -SpaceAfterCStyleCast: true -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 0 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -TabWidth: 8 -UseTab: ForContinuationAndIndentation diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index 53466ac..0000000 --- a/.clang-tidy +++ /dev/null @@ -1,31 +0,0 @@ -Checks: >- - bugprone-*, - cppcoreguidelines-*, - google-*, - misc-*, - modernize-*, - performance-*, - readability-*, - -bugprone-lambda-function-name, - -bugprone-easily-swappable-parameters, - -bugprone-reserved-identifier, - -cppcoreguidelines-avoid-goto, - -cppcoreguidelines-avoid-magic-numbers, - -cppcoreguidelines-avoid-non-const-global-variables, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, - -cppcoreguidelines-pro-bounds-pointer-arithmetic, - -cppcoreguidelines-pro-type-vararg, - -google-readability-braces-around-statements, - -google-readability-function-size, - -misc-no-recursion, - -modernize-return-braced-init-list, - -modernize-use-nodiscard, - -modernize-use-trailing-return-type, - -performance-unnecessary-value-param, - -readability-identifier-length, - -readability-magic-numbers - -CheckOptions: - readability-function-cognitive-complexity.Threshold: 100 - readability-function-cognitive-complexity.IgnoreMacros: true - readability-identifier-naming.ClassCase: CamelCase diff --git a/.gitignore b/.gitignore index cf2b2b7..96340aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1 @@ -*.o - -build -cmake-build-* -sgard +/sgard diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 79b3c94..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 9845628..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/sgard.iml b/.idea/sgard.iml deleted file mode 100644 index f08604b..0000000 --- a/.idea/sgard.iml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.trunk/.gitignore b/.trunk/.gitignore deleted file mode 100644 index 1e24652..0000000 --- a/.trunk/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*out -*logs -*actions -*notifications -*tools -plugins -user_trunk.yaml -user.yaml diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc deleted file mode 100644 index 8c7b1ad..0000000 --- a/.trunk/configs/.shellcheckrc +++ /dev/null @@ -1,7 +0,0 @@ -enable=all -source-path=SCRIPTDIR -disable=SC2154 - -# If you're having issues with shellcheck following source, disable the errors via: -# disable=SC1090 -# disable=SC1091 diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml deleted file mode 100644 index 4d44466..0000000 --- a/.trunk/configs/.yamllint.yaml +++ /dev/null @@ -1,10 +0,0 @@ -rules: - quoted-strings: - required: only-when-needed - extra-allowed: ["{|}"] - empty-values: - forbid-in-block-mappings: true - forbid-in-flow-mappings: true - key-duplicates: {} - octal-values: - forbid-implicit-octal: true diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml deleted file mode 100644 index fff3f81..0000000 --- a/.trunk/trunk.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# This file controls the behavior of Trunk: https://docs.trunk.io/cli -# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml -version: 0.1 -cli: - version: 1.17.1 -plugins: - sources: - - id: trunk - ref: v1.2.6 - uri: https://github.com/trunk-io/plugins -runtimes: - enabled: - - go@1.21.0 - - node@18.12.1 - - python@3.10.8 -lint: - enabled: - - checkov@2.5.9 - - clang-format@16.0.3 - - clang-tidy@16.0.3 - - git-diff-check - - prettier@3.0.3 - - shellcheck@0.9.0 - - shfmt@3.6.0 - - trivy@0.46.0 - - trufflehog@3.60.0 - - yamllint@1.32.0 -actions: - disabled: - - trunk-announce - - trunk-check-pre-push - - trunk-fmt-pre-commit - enabled: - - trunk-upgrade-available diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 50a7e66..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -cmake_minimum_required(VERSION 3.22) - -project(sgard VERSION 0.0.1 - LANGUAGES CXX - DESCRIPTION "Shimmer Clarity Gardener: A dot-files manager.") - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_VERBOSE_MAKEFILES TRUE) - -find_package(Protobuf REQUIRED) -find_package(scsl REQUIRED) - -file(GLOB ProtoFiles "${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto") -PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories(${SCSL_INCLUDE_DIRS}) - -add_library(protolib STATIC ${ProtoSources} ${ProtoHeaders}) -target_link_libraries(protolib INTERFACE ${Protobuf_LIBRARIES}) - -add_compile_options( - "-static" - "-Werror" "-Wextra" "-Wall" - "-Weffc++" -) - -if (CMAKE_BUILD_TYPE STREQUAL Debug) - add_compile_options("-g" "-fsanitize=address") -endif () - -set(HEADER_FILES - -) - -set(SOURCE_FILES sgard.cc) - -add_executable(sgard ${SOURCE_FILES}) -target_link_libraries(sgard protolib ${SCSL_LIBRARIES}) diff --git a/PROGRESS.md b/PROGRESS.md index 2e382d2..eea00e9 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -7,22 +7,24 @@ ARCHITECTURE.md for design details. ## Current Status -**Phase:** Pre-implementation — design complete, ready to begin Step 1. +**Phase:** Step 1 complete. Ready for Steps 2 & 3 (can be parallel). **Last updated:** 2026-03-23 ## Completed Steps -(none yet) +- **Step 1: Project Scaffolding** — removed old C++ files and `.trunk/` config, + initialized Go module, added cobra + yaml.v3 deps, created package dirs, + set up cobra root command with `--repo` flag. ## In Progress -(none yet) +(none) ## Up Next -Step 1: Project Scaffolding — remove old C++ files, initialize Go module, -create directory structure, set up cobra root command. +Step 2 (Manifest Package) and Step 3 (Store Package) — these can be done +in parallel. ## Known Issues / Decisions Deferred @@ -36,3 +38,4 @@ create directory structure, set up cobra root command. | Date | Step | Summary | |---|---|---| | 2026-03-23 | — | Design phase complete. ARCHITECTURE.md and PROJECT_PLAN.md written. | +| 2026-03-23 | 1 | Scaffolding complete. Old C++ removed, Go module initialized, cobra root command. | diff --git a/PROJECT_PLAN.md b/PROJECT_PLAN.md index 7e48773..bb503fe 100644 --- a/PROJECT_PLAN.md +++ b/PROJECT_PLAN.md @@ -6,13 +6,13 @@ Implementation plan for sgard. See ARCHITECTURE.md for design details. Remove old C++ source files and set up the Go project. -- [ ] Remove old files: `sgard.cc`, `proto/`, `CMakeLists.txt`, `scripts/`, `.clang-format`, `.clang-tidy`, `.idea/` -- [ ] `go mod init github.com/kisom/sgard` -- [ ] Add dependencies: `gopkg.in/yaml.v3`, `github.com/spf13/cobra` -- [ ] Create directory structure: `cmd/sgard/`, `manifest/`, `store/`, `garden/` -- [ ] Set up `cmd/sgard/main.go` with cobra root command and `--repo` persistent flag -- [ ] Update CLAUDE.md to reflect Go project -- [ ] Verify: `go build ./...` compiles clean +- [x] Remove old files: `sgard.cc`, `proto/`, `CMakeLists.txt`, `scripts/`, `.clang-format`, `.clang-tidy`, `.idea/`, `.trunk/` +- [x] `go mod init github.com/kisom/sgard` +- [x] Add dependencies: `gopkg.in/yaml.v3`, `github.com/spf13/cobra` +- [x] Create directory structure: `cmd/sgard/`, `manifest/`, `store/`, `garden/` +- [x] Set up `cmd/sgard/main.go` with cobra root command and `--repo` persistent flag +- [x] Update CLAUDE.md to reflect Go project +- [x] Verify: `go build ./...` compiles clean ## Step 2: Manifest Package diff --git a/cmd/sgard/main.go b/cmd/sgard/main.go new file mode 100644 index 0000000..d9f6feb --- /dev/null +++ b/cmd/sgard/main.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/spf13/cobra" +) + +var repoFlag string + +var rootCmd = &cobra.Command{ + Use: "sgard", + Short: "Shimmering Clarity Gardener: dotfile management", +} + +func defaultRepo() string { + home, err := os.UserHomeDir() + if err != nil { + return ".sgard" + } + return filepath.Join(home, ".sgard") +} + +func main() { + rootCmd.PersistentFlags().StringVar(&repoFlag, "repo", defaultRepo(), "path to sgard repository") + + if err := rootCmd.Execute(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5a299d4 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/kisom/sgard + +go 1.25.7 + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/cobra v1.10.2 // indirect + github.com/spf13/pflag v1.0.9 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ff4d6ec --- /dev/null +++ b/go.sum @@ -0,0 +1,12 @@ +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.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/proto/header.proto b/proto/header.proto deleted file mode 100644 index 1484927..0000000 --- a/proto/header.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = 'proto3'; -package sgardpb; - -import "google/protobuf/timestamp.proto"; - -// Header defines common metadata for messages in sgard. -message Header -{ - uint32 version = 1; - google.protobuf.Timestamp created = 2; - google.protobuf.Timestamp updated = 3; -} diff --git a/proto/homedir.proto b/proto/homedir.proto deleted file mode 100644 index 88d9a91..0000000 --- a/proto/homedir.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = 'proto3'; -package sgardpb; - -import 'header.proto'; -import 'path.proto'; - -message HomeDir -{ - Header header = 1; - - map files = 5; -}; diff --git a/proto/path.proto b/proto/path.proto deleted file mode 100644 index 6671208..0000000 --- a/proto/path.proto +++ /dev/null @@ -1,33 +0,0 @@ -syntax = 'proto3'; -package sgardpb; - -import 'header.proto'; -import "google/protobuf/timestamp.proto"; - -enum PathType { - PATHTYPE_UNSPECIFIED = 0; - PATHTYPE_FILE = 1; - PATHTYPE_DIRECTORY = 2; - PATHTYPE_LINK = 3; -}; - -message FilePath -{ - Header header = 1; - - string source_path = 2; - string dest_path = 3; - // todo: add mode, action (e.g. copy vs link) -}; - - -message Source -{ - Header header = 1; - PathType path_type = 2; - - oneof path - { - FilePath file = 5; - }; -}; diff --git a/scripts/install-depdendencies.sh b/scripts/install-depdendencies.sh deleted file mode 100755 index 9719466..0000000 --- a/scripts/install-depdendencies.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash - -##################################################################### -# This script attempts to install the appopriate build dependencies # -# for the host system. # -# # -# For platforms marked as unverified, it means that I was able to # -# start a Docker container for that platform and could look up the # -# right package names. I haven't actually tried building on these # -# platforms. # -# # -# This is primarily developed on the latest Ubuntu LTS release and # -# MacOS; other platforms are best-effort. # -##################################################################### - -set -eu - -install_debianesque() { - echo "[+] distribution is ${DISTRIB_ID}, choosing Debianesque install." - - echo "[+] installing tools" - sudo apt-get install git cmake clang scdoc - - echo "[+] installing protobuf libraries and development headers" - sudo apt-get install protobuf-compiler libprotobuf-dev - - echo "[+] installing gRPC libraries and development headers" - sudo apt-get install protobuf-compiler-grpc grpc-proto libgrpc++-dev -} - -install_redhat() { - echo "[+] distribution is ${DISTRIB_ID}, choosing Redhat install." - echo "[!] WARNING: installation for Redhat systems is unverified." - - echo "[+] installing tools" - sudo dnf install git cmake clang scdoc - - echo "[+] installing libraries and development headers" - sudo dnf install protobuf-compiler libprotobuf-dev -} - -install_alpine() { - echo "[+] distribution is ${DISTRIB_ID}, choosing Alpine install." - echo "[!] WARNING: installation for Alpine systems is unverified." - - echo "[+] installing tools" - sudo dnf install git cmake clang scdoc - - echo "[+] installing libraries and development headers" - sudo dnf install sdl2-dev freetype-dev protobuf-compiler-grpc -} - -install_macos() { - # TODO: consider supporting macports? - echo "[+] host system is MacOS" - - echo "[+] installing tools" - brew install git cmake scdoc - - echo "[+] installing libraries and development headers" - # TODO: look up proper package names in homebrew -} - -install_linux() { - echo "[+] host system is Linux" - [[ -f "/etc/lsb-release" ]] && source /etc/lsb-release - if [ -z "${DISTRIB_ID}" ]; then - if [ -d /etc/apt ]; then - DISTRIB_ID="apt-based" - elif [ -f /etc/alpine-release ]; then - DISTRIB_ID=Alpine - elif [ -d /etc/dnf -o /etc/yum.repos.d ]; then - # I don't use Fedora, this is based on a cursory - # glance at the filesystem on a Docker image. - DISTRIB_ID="Fedora" - fi - fi - - case ${DISTRIB_ID} in - Ubuntu) install_debianesque ;; - Debian) install_debianesque ;; - apt-based) install_debianesque ;; - Fedora) install_redhat ;; - Alpine) install_alpine ;; - - *) - echo "[!] distribution ${DISTRIB_ID} isn't supported in this script." >/dev/null - ;; - esac -} - -case "$(uname -s)" in -Linux) install_linux ;; -Darwin) install_macos ;; -*) - echo "[!] platform $(uname -s) isn't supported in this script." >/dev/null - ;; -esac diff --git a/sgard.cc b/sgard.cc deleted file mode 100644 index d2eaa2b..0000000 --- a/sgard.cc +++ /dev/null @@ -1,25 +0,0 @@ -/// -/// \file sgard.cc -/// \author K. Isom -/// \date 2023-10-17 -/// \brief Shimmering Clarity Gardener: dot-file management. -/// - -#include - -#include - - -int -main(int argc, char *argv[]) -{ - auto flag = new scsl::Flags("sgard", "Shimmering Clarity Gardener: dot-file management"); - - auto parseResult = flag->Parse(argc, argv); - if (parseResult != scsl::Flags::ParseStatus::OK) { - std::cerr << "failed to parse flags: " - << scsl::Flags::ParseStatusToString(parseResult) - << "\n"; - flag->Usage(std::cerr, 1); - } -}