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 " Usage: echo '1+1' | hylite\n\n Syntax Highlighting for Scripters.\n\n Finds an existing syntax highlighting tool (rouge, coderay, pygments),\n and uses that to highlight the code.\n\n Options:\n -h This help screen\n -l LANG Set the language (defaults to Ruby)\n\n Examples:\n Set the language to JavaScript\n $ echo 'function alphabet() { console.log(\"abc\"); }' | hylite -l javascript\n\n Add syntax highlighting to `cat`\n $ cat lib/hylite.rb | hylite\n\n Highlight sassy style sheets\n $ cat app/assets/stylesheets/site.css.scss | hylite -l scss\n HELP\nend\n" |
#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 |