Class: Kolor::CLI
- Inherits:
-
Object
- Object
- Kolor::CLI
- Defined in:
- lib/kolor/cli.rb
Overview
Kolor::CLI provides a command-line interface for the Kolor library.
It supports:
-
Foreground and background colors
-
Text styles (bold, underline, etc.)
-
Predefined themes (via kolor/extra)
-
RGB and hex color input
-
Gradients and rainbow effects
-
Utility commands like listing options or showing a demo
Input can be passed as arguments or piped via stdin. Output is automatically colorized unless redirected, in which case colors are disabled unless ‘KOLOR_FORCE` is set.
Instance Method Summary collapse
-
#initialize(args = ARGV) ⇒ CLI
constructor
Initializes the CLI with given arguments.
-
#run ⇒ void
Runs the CLI command.
Constructor Details
#initialize(args = ARGV) ⇒ CLI
Initializes the CLI with given arguments.
41 42 43 44 |
# File 'lib/kolor/cli.rb', line 41 def initialize(args = ARGV) @args = args @options = {} end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Runs the CLI command.
Loads config, parses options, and dispatches to appropriate handler.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/kolor/cli.rb', line 52 def run Kolor::Config.init if extra_available? if @options[:list_colors] list_colors elsif @options[:list_styles] list_styles elsif @options[:list_themes] list_themes elsif @options[:demo] show_demo elsif @options[:version] puts "Kolor #{Kolor::VERSION}" elsif @options[:help] puts @option_parser else colorize_text end end |