How abhimanyu003/sttr works
Project type and purpose
• This is a Go-based command-line application (“sttr”) that performs a wide variety of string transformation and processing operations.
• It exposes a single binary (sttr) with subcommands (md5, base64-encode, json-yaml, etc.) that can read from stdin, files, or shell pipes.
File structure
• Top-level:
• main.go – entrypoint, kicks off the root CLI command
• cmd/ – Cobra commands for each operation and global commands (version, completion, interactive)
• processors/ – core implementation of each transformation, conforming to a Processor interface
• ui/ – interactive mode code (terminal UI)
• utils/ – shared helper functions (e.g., text I/O)
• hugo/ – static site for docs (built with Hugo)
• CI/CD and release tooling: .github/workflows/, goreleaser.yml, Dockerfile, install scripts
README for additional insights
• Usage patterns: direct invocation, piping, file I/O, chaining commands
• Supported operations are grouped by category (Encode/Decode, Hash, String, etc.)
• Installation methods and release artifacts (binaries, containers, package managers)
Main components
a. User Interface
• Shell user invoking sttr with arguments or using stdin/stdout
b. CLI Layer
• main.go → Cobra root command (cmd/root.go)
• Subcommands (cmd/processor_*.go, cmd/version.go, cmd/completion.go, cmd/interactive.go)
c. Core Processing Layer
• Processor interface (defined in processors/processor.go)
• Individual processor modules (ASCII85, base64, md5, etc.)
• Utilities (utils/text.go) used by processors
d. I/O Layer
• STDIN/STDOUT, file reads/writes
• Chaining pipes between commands
e. Documentation Site
• Hugo site (hugo/) for CLI reference and user docs
f. Build & Release Pipeline
• GitHub Actions (.github/workflows/) → Go build, tests
• goreleaser (Docker, binaries for multiple platforms)
• install scripts (install.sh)
Relationships and interactions
• User invokes CLI → Cobra root → dispatch to specific subcommand → instantiate corresponding Processor → read input (stdin/file) via utils → execute transformation → write output to stdout/file.
• In interactive mode: Cobra interactive command → ui layer → loop: get user input → pass to Processor → display in terminal UI.
• Documentation build is a separate pipeline: Hugo reads hugo/ folder → outputs static site.
• CI/CD pipeline triggers on push/tags → runs tests in processors/ and cmd/ → builds binaries via goreleaser → publishes to GitHub Releases, Docker registry, package managers.
Architectural patterns and design principles
• Modular command pattern using Cobra
• Plugin-like Processor interface for easy addition of new transformations
• Separation of concerns: CLI parsing (cmd/), core logic (processors/), I/O helpers (utils/), UI code (ui/), docs (hugo/), build config separately
• Unix philosophy: small composable tools chaining via pipes