Class: Machinator::ConsoleInterface
- Inherits:
-
Object
- Object
- Machinator::ConsoleInterface
- Defined in:
- lib/machinator/console_interface.rb
Constant Summary collapse
- VERSION_TEXT =
'0.1'- HELP =
<<TEXT == Machinator obfuscate file content and directory structures == Usage machinator [options] == Options -h, --help Displays help message -v, --version Displays the version TEXT
Instance Method Summary collapse
- #handle_exception(e) ⇒ Object
-
#initialize ⇒ ConsoleInterface
constructor
A new instance of ConsoleInterface.
- #interpret(argv) ⇒ Object
- #parsed_options? ⇒ Boolean
- #peace_out(msg) ⇒ Object
Constructor Details
#initialize ⇒ ConsoleInterface
Returns a new instance of ConsoleInterface.
21 22 23 |
# File 'lib/machinator/console_interface.rb', line 21 def initialize @options = OpenStruct.new end |
Instance Method Details
#handle_exception(e) ⇒ Object
52 53 54 55 56 |
# File 'lib/machinator/console_interface.rb', line 52 def handle_exception(e) puts("\nshit pooped!\n\n") puts "#{e.class.to_s} ==> #{e.}\n\n" puts e.backtrace.join("\n") end |
#interpret(argv) ⇒ Object
25 26 27 28 |
# File 'lib/machinator/console_interface.rb', line 25 def interpret(argv) @argv = argv end |
#parsed_options? ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/machinator/console_interface.rb', line 34 def @options.verbose = false opts = OptionParser.new opts.on('-v', '--version') { peace_out(VERSION_TEXT) } opts.on('-h', '--help') { peace_out(HELP) } opts.on('-o', '--obfuscate [path]') { |path| } begin opts.parse!(@argv) rescue Exception => e handle_exception(e) ; exit!(0) end true end |
#peace_out(msg) ⇒ Object
30 31 32 |
# File 'lib/machinator/console_interface.rb', line 30 def peace_out(msg) puts(msg) ; exit!(0) end |