Move demo implementation to examples/demo.rb#14
Conversation
Extract demo code from lib/clack.rb to examples/demo.rb, add proxy method.
Greptile Overview
|
| Filename | Overview |
|---|---|
| clack.gemspec | Added examples directory to gem files for distribution |
| lib/clack.rb | Replaced inline demo implementation with proxy method that loads examples/demo.rb |
| examples/demo.rb | Extracted demo code from lib/clack.rb into standalone, executable example file |
Sequence Diagram
sequenceDiagram
participant User
participant ClackDemo as clack-demo (exe)
participant ClackModule as Clack module (lib/clack.rb)
participant DemoFile as examples/demo.rb
participant Prompts as Clack Prompts
User->>ClackDemo: Execute clack-demo
ClackDemo->>ClackModule: Clack.demo()
ClackModule->>ClackModule: File.expand_path("../examples/demo.rb", __dir__)
ClackModule->>DemoFile: load demo_path
DemoFile->>DemoFile: Define run_demo function
ClackModule->>DemoFile: run_demo()
DemoFile->>Prompts: Clack.intro("clack-demo")
DemoFile->>Prompts: Clack.group(on_cancel: ...) { ... }
Prompts-->>User: Display prompts (name, directory, template, etc.)
User-->>Prompts: Provide responses
Prompts-->>DemoFile: Return result hash
DemoFile->>DemoFile: Check if Clack.cancel?(result)
DemoFile->>Prompts: Clack.autocomplete(...)
DemoFile->>Prompts: Clack.select_key(...)
DemoFile->>Prompts: Clack.path(...)
DemoFile->>Prompts: Clack.group_multiselect(...)
DemoFile->>Prompts: Clack.progress(...)
DemoFile->>Prompts: Clack.tasks(...)
DemoFile->>Prompts: Clack.spinner()
DemoFile->>Prompts: Clack.log.step(...)
DemoFile->>Prompts: Clack.note(...)
DemoFile->>Prompts: Clack.outro("Happy coding!")
DemoFile-->>ClackModule: Demo complete
ClackModule-->>ClackDemo: Return
ClackDemo-->>User: Exit
Code ReviewI found one critical issue that needs to be addressed: Missing examples directory in gem packageThe The method tries to load def demo
demo_path = File.expand_path("../examples/demo.rb", __dir__)
load demo_path
run_demo
endHowever, the gemspec at clack.gemspec:26 does not include the examples directory: spec.files = Dir["lib/**/*", "LICENSE", "README.md", "CHANGELOG.md"]When users install the gem via Suggested fix: Update spec.files = Dir["lib/**/*", "examples/**/*", "LICENSE", "README.md", "CHANGELOG.md"] |
Use handle_cancel instead of cancel? to show cancellation messages. Include examples directory in gem files.
|
@claude @greptileai re-review plz |
|
Claude finished @swhitt's task in 46s —— View job Re-review Complete ✅
Review SummaryGreat work addressing the previous critical issue! The gemspec now correctly includes the examples directory at clack.gemspec:26: spec.files = Dir["lib/**/*", "examples/**/*", "LICENSE", "README.md", "CHANGELOG.md"]This means Inconsistent Cancel HandlingHowever, there's one inconsistency in the cancel handling within Line 83 uses return if Clack.handle_cancel(color)But line 76 uses return if Clack.cancel?(result)Impact: When using Recommendation: For consistency and better UX, use Lines affected: examples/demo.rb:76, 83, 94, 101, 134 Other Changes Look Good
VerdictThe critical issue has been resolved ✅. The only remaining concern is the minor inconsistency in cancel handling, which affects UX but not functionality. This is optional to fix but recommended for polish. |
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Extract demo code from lib/clack.rb to examples/demo.rb, add proxy method.