Improve CLI Output, with a Formatter class
👋 Hiya!
[!CAUTION] This PR is draft, I'm looking for feedback on this and only the
hanami newcommand 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
Formatterclass and methods that can be used with the existing out.puts code since it's just putting the text and needing color codes.
Screenshots
TODO
- [x] Add specs (can't live with em, can't live without em).
- [x] Test other commands + fix specs