Skip to content

Establish coding standards and improve script consistency #21

@slifty

Description

@slifty

Problem

Installation scripts lack consistency in style, formatting, and patterns, making the codebase harder to maintain and contribute to.

Inconsistencies

1. Output Formatting

  • Some scripts use echo, others use printf
  • Some use emojis (🛠, ✅, 🔑), others don't
  • No consistent logging format
  • bootstrap.sh has nice colored output functions (info, success, fail) but they're not used in individual install scripts

2. Code Style

  • Mixed indentation (tabs vs spaces)
  • Inconsistent variable naming
  • Some scripts have descriptive comments, others don't
  • Different approaches to checking command existence (test $(which cmd) vs command -v cmd)

3. Script Structure

  • No common pattern across install.sh files
  • Some scripts are verbose, others minimal
  • Inconsistent error handling patterns
  • No standard header/documentation format

Impact

  • Harder to review changes
  • Inconsistent user experience
  • Makes automation and tooling difficult
  • Higher barrier for contributors

Recommended Solution

1. Create a Style Guide

Document in AGENTS.md or CONTRIBUTING.md:

  • Use printf for output (more portable than echo)
  • Use emojis consistently or not at all
  • Standard indentation (2 spaces or tabs - pick one)
  • Naming conventions for variables (UPPERCASE for globals/env vars, lowercase for locals)
  • Comment standards

2. Create Shared Functions

Move bootstrap.sh output functions to a shared file:

# dotfiles/lib/functions.sh
info() { printf "\r  [ \033[00;34m..\033[0m ] $1\n"; }
user() { printf "\r  [ \033[0;33m??\033[0m ] $1\n"; }
success() { printf "\r\033[2K  [ \033[00;32mOK\033[0m ] $1\n"; }
fail() { printf "\r\033[2K  [\033[0;31mFAIL\033[0m] $1\n"; }

Then source in scripts:

source ~/.dotfiles/lib/functions.sh
info "Installing something..."

3. Create Template Scripts

Provide template files for new topics:

  • _template/install.sh
  • _template/preinstall.sh
  • _template/env.zsh

4. Standardize Command Checks

Use consistent pattern:

if ! command -v tool &> /dev/null; then
  fail "tool not found"
fi

Success Criteria

  • Documented style guide
  • Shared utility functions
  • Template scripts for new topics
  • Consistent look and feel across all scripts

Priority

LOW - Nice to have, should be done incrementally as other issues are addressed

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions