Skip to content

Commit 65ad5ea

Browse files
committed
initial commit
0 parents  commit 65ad5ea

36 files changed

+3888
-0
lines changed

.claude/CLAUDE.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build & Run
6+
7+
```bash
8+
go build -o sshto . # Build binary
9+
go run . # Run directly
10+
go mod tidy # Update dependencies
11+
```
12+
13+
## Architecture
14+
15+
```
16+
cmd/ # Cobra CLI commands (thin layer, orchestrates app)
17+
internal/
18+
app/ # Application orchestration, dependency injection
19+
config/ # YAML config load/save, Server/Group models
20+
ssh/ # SSH command execution
21+
ui/ # Bubbletea TUI components (list, form, styles)
22+
```
23+
24+
**Flow**: `cmd``app.App``config.Config` + `ssh.Client` + `ui.*`
25+
26+
## Key Patterns
27+
28+
- **Config location**: `~/.config/sshto/config.yaml`
29+
- **Models**: `config.Server` and `config.Group` with YAML tags
30+
- **App struct**: Holds Config and SSHClient, resolves defaults/overrides
31+
- **TUI**: Bubbletea models in `internal/ui/` with Lipgloss styling
32+
33+
## CLI Usage
34+
35+
```bash
36+
sshto # Interactive fuzzy finder
37+
sshto <server> # Direct connect
38+
sshto <server> -u root # Connect with user override
39+
sshto list -g production # Filter by group
40+
sshto add # Interactive add form
41+
sshto edit <server> # Interactive edit form
42+
sshto remove <server> # Remove with confirmation
43+
sshto groups # List groups
44+
sshto groups add <name> # Add group
45+
```
46+
47+
## Config Schema
48+
49+
```yaml
50+
groups:
51+
- name: production
52+
color: red # red, green, yellow, blue, magenta, cyan, white, gray
53+
54+
servers:
55+
- name: web-prod
56+
host: 192.168.1.10
57+
user: deploy
58+
port: 22
59+
key: ~/.ssh/id_rsa
60+
group: production
61+
62+
defaults:
63+
user: ""
64+
port: 22
65+
key: ""
66+
```

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, macos-latest]
16+
go-version: ['1.24', 'stable']
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
26+
- name: Download dependencies
27+
run: go mod download
28+
29+
- name: Check formatting
30+
run: |
31+
if [ -n "$(gofmt -l .)" ]; then
32+
echo "Code is not formatted. Run 'make fmt'"
33+
gofmt -d .
34+
exit 1
35+
fi
36+
37+
- name: Run go vet
38+
run: go vet ./...
39+
40+
- name: Run tests
41+
run: go test -v -race -coverprofile=coverage.txt ./...
42+
43+
- name: Upload coverage
44+
uses: codecov/codecov-action@v4
45+
if: matrix.os == 'ubuntu-latest' && matrix.go-version == 'stable'
46+
with:
47+
file: ./coverage.txt
48+
fail_ci_if_error: false
49+
50+
build:
51+
name: Build
52+
runs-on: ${{ matrix.os }}
53+
strategy:
54+
matrix:
55+
os: [ubuntu-latest, macos-latest, windows-latest]
56+
go-version: ['1.24']
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Setup Go
62+
uses: actions/setup-go@v5
63+
with:
64+
go-version: ${{ matrix.go-version }}
65+
66+
- name: Build (Unix)
67+
if: matrix.os != 'windows-latest'
68+
run: go build -o bin/sshto .
69+
70+
- name: Build (Windows)
71+
if: matrix.os == 'windows-latest'
72+
run: go build -o bin/sshto.exe .

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Go build artifacts
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
bin/
8+
9+
# Test artifacts
10+
*.test
11+
*.out
12+
coverage.html
13+
coverage.txt
14+
15+
# Dependency directories
16+
vendor/
17+
18+
# IDE and editor files
19+
.idea/
20+
*.swp
21+
*.swo
22+
*~
23+
.vscode/
24+
25+
# OS-specific files
26+
.DS_Store
27+
.DS_Store?
28+
Thumbs.db
29+
30+
# Environment and secrets
31+
.env
32+
.env.*
33+
*.pem
34+
credentials.json
35+
36+
# Debug files
37+
debug
38+
*.log

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.1.0] - 2024-12-14
11+
12+
### Added
13+
14+
- Interactive fuzzy finder for quick server selection using Bubbletea TUI
15+
- Server management commands: `add`, `edit`, `remove`, `list`
16+
- Group support with color-coded organization (red, green, yellow, blue, magenta, cyan, white, gray)
17+
- YAML-based configuration stored at `~/.config/sshto/config.yaml`
18+
- Direct connection via `sshto <server>` command
19+
- User override support with `-u` flag
20+
- Group filtering with `-g` flag for list command
21+
- Default settings for user, port, and SSH key
22+
- Input validation for hosts, ports, and server names
23+
- Beautiful terminal UI with Lipgloss styling
24+
25+
[Unreleased]: https://github.com/codoworks/sshto/compare/v0.1.0...HEAD
26+
[0.1.0]: https://github.com/codoworks/sshto/releases/tag/v0.1.0

CONTRIBUTING.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Contributing to sshto
2+
3+
Thank you for your interest in contributing to sshto! This document provides guidelines and instructions for contributing.
4+
5+
## Prerequisites
6+
7+
- Go 1.24 or later
8+
- Git
9+
10+
## Development Setup
11+
12+
1. Fork and clone the repository:
13+
```bash
14+
git clone https://github.com/YOUR_USERNAME/sshto.git
15+
cd sshto
16+
```
17+
18+
2. Install dependencies:
19+
```bash
20+
go mod tidy
21+
```
22+
23+
3. Build the project:
24+
```bash
25+
make build
26+
```
27+
28+
4. Run tests:
29+
```bash
30+
make test
31+
```
32+
33+
## Code Style
34+
35+
- Run `make fmt` before committing
36+
- Run `make vet` to check for common issues
37+
- Run `make lint` for comprehensive linting (requires golangci-lint)
38+
- Follow standard Go conventions and idioms
39+
40+
## Making Changes
41+
42+
1. Create a new branch for your feature or fix:
43+
```bash
44+
git checkout -b feature/your-feature-name
45+
```
46+
47+
2. Make your changes and commit with clear, descriptive messages
48+
49+
3. Ensure all tests pass:
50+
```bash
51+
make test
52+
```
53+
54+
4. Push to your fork and open a pull request
55+
56+
## Pull Request Guidelines
57+
58+
- Provide a clear description of the changes
59+
- Reference any related issues
60+
- Ensure CI checks pass
61+
- Keep changes focused and atomic
62+
63+
## Reporting Issues
64+
65+
When reporting issues, please include:
66+
67+
- A clear description of the problem
68+
- Steps to reproduce
69+
- Expected vs actual behavior
70+
- Go version and operating system
71+
- Relevant configuration (with sensitive data removed)
72+
73+
## Questions?
74+
75+
Feel free to open an issue for questions or discussion.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 codoworks
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Project variables
2+
BINARY_NAME := sshto
3+
OUTPUT_DIR := bin
4+
MODULE := github.com/codoworks/sshto
5+
6+
# Go commands
7+
GO := go
8+
GOFMT := gofmt
9+
GOVET := $(GO) vet
10+
GOTEST := $(GO) test
11+
GOBUILD := $(GO) build
12+
13+
# Build flags
14+
LDFLAGS := -s -w
15+
16+
.PHONY: all build test test-coverage fmt fmt-check vet lint clean install tidy help
17+
18+
## all: Build the binary (default target)
19+
all: build
20+
21+
## build: Build the binary to bin/
22+
build:
23+
@mkdir -p $(OUTPUT_DIR)
24+
$(GOBUILD) -ldflags "$(LDFLAGS)" -o $(OUTPUT_DIR)/$(BINARY_NAME) .
25+
26+
## test: Run all tests
27+
test:
28+
$(GOTEST) -v -race ./...
29+
30+
## test-coverage: Run tests with coverage report
31+
test-coverage:
32+
$(GOTEST) -v -race -coverprofile=coverage.txt -covermode=atomic ./...
33+
$(GO) tool cover -html=coverage.txt -o coverage.html
34+
35+
## fmt: Format all Go files
36+
fmt:
37+
$(GOFMT) -w .
38+
39+
## fmt-check: Check if code is formatted
40+
fmt-check:
41+
@if [ -n "$$($(GOFMT) -l .)" ]; then \
42+
echo "Code is not formatted. Run 'make fmt'"; \
43+
$(GOFMT) -d .; \
44+
exit 1; \
45+
fi
46+
47+
## vet: Run go vet
48+
vet:
49+
$(GOVET) ./...
50+
51+
## lint: Run golangci-lint (requires golangci-lint installed)
52+
lint:
53+
@which golangci-lint > /dev/null || (echo "golangci-lint not installed. Run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
54+
golangci-lint run ./...
55+
56+
## clean: Remove build artifacts
57+
clean:
58+
rm -rf $(OUTPUT_DIR)
59+
rm -f coverage.txt coverage.html
60+
61+
## install: Install binary to GOPATH/bin
62+
install:
63+
$(GOBUILD) -ldflags "$(LDFLAGS)" -o $(GOPATH)/bin/$(BINARY_NAME) .
64+
65+
## tidy: Tidy and verify module dependencies
66+
tidy:
67+
$(GO) mod tidy
68+
$(GO) mod verify
69+
70+
## help: Show this help message
71+
help:
72+
@echo "Usage: make [target]"
73+
@echo ""
74+
@echo "Targets:"
75+
@sed -n 's/^## //p' $(MAKEFILE_LIST) | column -t -s ':' | sed 's/^/ /'

0 commit comments

Comments
 (0)