cli icon indicating copy to clipboard operation
cli copied to clipboard

Improve CLI Output, with a Formatter class

Open afomera opened this issue 4 months ago • 0 comments

👋 Hiya!

[!CAUTION] This PR is draft, I'm looking for feedback on this and only the hanami new command has been tested so far, some output in other commands may not look quite right. Once we determine the approach I'll work on coordinating updating the other commands / testing them.

This is the first stab at an incremental approach to improving the CLI Output to look nice and appealing for users using it.

Following the discussion in https://github.com/hanami/roadmap/issues/11 I wanted to take a try at this and see if I could get my feet involved and put the code to the metal.

Additions

Hanami::CLI::Formatter class

Meant to be private internal, but provides us with an interface to take some text and some semantic methods (success, warning, info, heading) and get back ANCI format codes + text.

Changes

Hanami::CLI::Commands::Gem::New

  • Updated the new command output to use the Formatter class

Hanami::CLI::Files class

  • New def created_directory(path) method for, you guessed it, announcing it created a directory.
  • Updated mkdir(path) method to use the created_directory method to announce it in the proper formatting.

Questions

  • Does this align with the vision? I normally would probably consider using a method but it seemed apt to make a Formatter class and methods that can be used with the existing out.puts code since it's just putting the text and needing color codes.

Screenshots

CleanShot 2025-09-29 at 18 27 53@2x

TODO

  • [x] Add specs (can't live with em, can't live without em).
  • [x] Test other commands + fix specs

afomera avatar Sep 30 '25 00:09 afomera