Skip to content

Refactor/move demo to examples#15

Merged
swhitt merged 3 commits intomainfrom
refactor/move-demo-to-examples
Jan 24, 2026
Merged

Refactor/move demo to examples#15
swhitt merged 3 commits intomainfrom
refactor/move-demo-to-examples

Conversation

@swhitt
Copy link
Copy Markdown
Owner

@swhitt swhitt commented Jan 24, 2026

The demo logic is moved out of the main library into a dedicated example script, and project configuration is updated to better handle the new structure and examples.

Extract demo code from lib/clack.rb to examples/demo.rb, add proxy method.
Use handle_cancel instead of cancel? to show cancellation messages.
Include examples directory in gem files.
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Jan 24, 2026

Greptile Overview

Greptile Summary

This PR successfully refactors the demo implementation by moving it from the main library file (lib/clack.rb) into a dedicated example script (examples/demo.rb). The changes improve code organization by separating example code from the core library, making the codebase more maintainable.

Key changes:

  • Extracted 165+ lines of demo code from lib/clack.rb into examples/demo.rb
  • Updated Clack.demo method to dynamically load and execute the demo script
  • Consistently uses Clack.handle_cancel instead of Clack.cancel? throughout the demo for better error handling
  • Configured build tools (Reek, Lefthook) to exclude the examples/ directory from code quality checks
  • Updated gemspec to package example files with the gem distribution

The refactoring maintains backward compatibility - the Clack.demo method and clack-demo executable continue to work as before.

Confidence Score: 5/5

  • This PR is safe to merge with no issues identified
  • The refactoring is clean and well-executed. The demo code was moved without functional changes (only improved cancel handling). All configuration files were properly updated to handle the new structure. The changes maintain backward compatibility and improve code organization.
  • No files require special attention

Important Files Changed

Filename Overview
clack.gemspec Added examples/**/* to packaged files so examples are distributed with the gem
lib/clack.rb Refactored demo method to load implementation from examples/demo.rb instead of containing inline code
examples/demo.rb Moved demo implementation from lib/clack.rb and consistently uses Clack.handle_cancel instead of Clack.cancel?

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as clack-demo (exe)
    participant Clack as Clack Module
    participant Demo as examples/demo.rb
    
    User->>CLI: Execute clack-demo
    CLI->>Clack: Clack.demo()
    Clack->>Clack: Resolve path to examples/demo.rb
    Clack->>Demo: load demo_path
    Demo->>Demo: Define run_demo()
    Clack->>Demo: Call run_demo()
    Demo->>Clack: Call various prompt methods
    Note over Demo,Clack: text, select, confirm, multiselect,<br/>autocomplete, select_key, path,<br/>group_multiselect, progress, tasks,<br/>spinner, log, note, outro
    Demo->>Demo: Check cancel with handle_cancel()
    Demo-->>User: Display interactive prompts
    User-->>Demo: Provide input
    Demo-->>User: Show results and summary
Loading

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@claude
Copy link
Copy Markdown

claude bot commented Jan 24, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@swhitt swhitt force-pushed the refactor/move-demo-to-examples branch from a685293 to 877eb75 Compare January 24, 2026 04:25
@swhitt swhitt merged commit 535aa6e into main Jan 24, 2026
4 checks passed
@swhitt swhitt deleted the refactor/move-demo-to-examples branch January 24, 2026 04:32
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.

1 participant