Cli flags and wiring#5
Merged
Merged
Conversation
Refactors the monolithic Validate() into focused private helpers and adds support for validating --from/--to window flags. Changes: - Add FromTime/ToTime fields to Config - Add validateModes() to reject mixed flag groups (--from/--to with --wake/--sleep) - Add validateWindow() for --from/--to pair validation - Extract validateTimeFlags(), validateBuffer(), validateCycles() as focused helpers - Add normalizeHour() to accept single-digit hours (e.g. 7:00) - Improve error messages to reference flag names (--wake, --sleep, etc.) Tests: - Add TestValidateWindow covering valid, missing, invalid, and mixed cases - Add TestValidateTimeFlagsMutualExclusion for both-set and neither-set - Add edge cases: zero buffer, equal min/max cycles, short hour formats - Fix test name "valid wake time format" -> "valid wake time short hour"
Adds pflag as a dependency to support shorthand CLI flags (e.g. -w, -s). The standard library flag package does not support single-character shorthands, so pflag is used as a drop-in replacement.
- Add CLI argument parsing using `spf13/pflag` to handle user input. - Implement `runWakeMode`, `runSleepMode`, and `runWindowMode` functions to process input and display cycle calculations. - Expose `NormalizeHour` in the `validate` package to ensure consistent input formatting across the app. - Update `main.go` entry point to validate flags and route execution to the selected mode. - Add `sleepycli` to `.gitignore` to exclude build artifacts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce the CLI entry point for sleepycli, allowing users to interact with the application via the terminal. Includes robust argument parsing, validation of sleep cycle parameters, and the execution logic for calculating sleep/wake times.
CLI Infrastructure
Validation Refactoring