Skip to content

moon.sh: a tiny POSIX moon-phase script - #4

Merged
testtest126 merged 2 commits into
mainfrom
claude/moon-emoji-uvv106
Jul 14, 2026
Merged

moon.sh: a tiny POSIX moon-phase script#4
testtest126 merged 2 commits into
mainfrom
claude/moon-emoji-uvv106

Conversation

@testtest126

Copy link
Copy Markdown
Owner

What & why

A small, dependency-free flourish for the repo: ./moon.sh prints the current phase of the Moon — emoji + name + age in days.

$ ./moon.sh
🌑  New Moon (day 28 of ~29.5)

It's deliberately standalone — not wired into install.sh, and not added under templates/ — so it doesn't change what the kit installs.

How it works

  • Integer arithmetic only (no floats, no deps): days since a known new moon (2000-01-06 18:14 UTC) modulo the synodic month (29.53 days), snapped to the nearest of the 8 named phases.
  • Optional EPOCH_SECONDS argument makes "now" injectable, which is what makes it deterministically testable and lets you check any date, not just today.
  • --help, unknown-option rejection, and non-numeric-input rejection mirror the argument-handling style already in install.sh.

Conventions followed

  • Pure POSIX sh (#!/usr/bin/env sh, set -eu, no bashisms) — passes shellcheck clean and runs under dash.
  • New tests/moon.bats pins every named phase, the age output, both error paths, --help, the pre-reference-timestamp guard, and a strict-POSIX (dash) run.

CI

The workflow hard-coded shellcheck install.sh and bats tests/install.bats, which would have left the new files unchecked. Broadened both to globs (./*.sh, tests/*.bats) so scripts and test files are picked up automatically — the same derive-don't-hand-maintain property install.sh already has for its copy list.

Verification

  • shellcheck ./*.sh → clean
  • bats tests/*.bats → 22/22 pass (10 install + 12 moon)
  • Ran ./moon.sh for real across new / first-quarter / full / waning-gibbous / last-quarter reference points, the default (today), the error paths, and under dash.

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits July 13, 2026 23:18
A small, dependency-free flourish: `./moon.sh` prints the current phase of
the Moon (emoji + name + age in days), computed with integer arithmetic from
a known new-moon reference and the synodic month. Pure POSIX sh, shellcheck
clean, and deliberately standalone — it is not wired into install.sh.

An optional epoch-seconds argument makes it fully testable; tests/moon.bats
pins every named phase plus the help and input-validation paths and runs
under dash.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016jGCQzWMQD3sBBbcvZtLyQ
Broaden the two hard-coded paths (`shellcheck install.sh`, `bats
tests/install.bats`) to globs so new scripts and test files are covered
automatically — the same derive-don't-hand-maintain property install.sh
already has for its copy list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016jGCQzWMQD3sBBbcvZtLyQ
@testtest126
testtest126 marked this pull request as ready for review July 14, 2026 16:23
@testtest126
testtest126 merged commit 2132ec0 into main Jul 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants