Class: Hylite::CLI
- Inherits:
-
Object
- Object
- Hylite::CLI
- Defined in:
- lib/hylite/cli.rb
Instance Method Summary collapse
- #config ⇒ Object
- #errors ⇒ Object
- #help_screen ⇒ Object
-
#initialize(stdin, argv) ⇒ CLI
constructor
A new instance of CLI.
- #result ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(stdin, argv) ⇒ CLI
Returns a new instance of CLI.
30 31 32 33 |
# File 'lib/hylite/cli.rb', line 30 def initialize(stdin, argv) self.stdin = stdin self.argv = argv end |
Instance Method Details
#config ⇒ Object
51 52 53 |
# File 'lib/hylite/cli.rb', line 51 def config @config ||= parse(argv) end |
#errors ⇒ Object
47 48 49 |
# File 'lib/hylite/cli.rb', line 47 def errors config.fetch :errors end |
#help_screen ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hylite/cli.rb', line 5 def help_screen <<-HELP Usage: echo '1+1' | hylite Syntax Highlighting for Scripters. Finds an existing syntax highlighting tool (rouge, coderay, pygments), and uses that to highlight the code. Options: -h This help screen -l LANG Set the language (defaults to Ruby) Examples: Set the language to JavaScript $ echo 'function alphabet() { console.log("abc"); }' | hylite -l javascript Add syntax highlighting to `cat` $ cat lib/hylite.rb | hylite Highlight sassy style sheets $ cat app/assets/stylesheets/site.css.scss | hylite -l scss HELP end |
#result ⇒ Object
35 36 37 38 39 |
# File 'lib/hylite/cli.rb', line 35 def result return help_screen if config[:help] ensure_evaluated @result end |
#success? ⇒ Boolean
41 42 43 44 45 |
# File 'lib/hylite/cli.rb', line 41 def success? return true if config[:help] ensure_evaluated errors.none? end |