Module: Trustworthy::CLI::Command
- Included in:
- Trustworthy::CLI, AddKey, Decrypt, Encrypt, Init
- Defined in:
- lib/trustworthy/cli/command.rb
Instance Method Summary collapse
- #default_options ⇒ Object
- #parse_options(command, args) ⇒ Object
- #print_help ⇒ Object
- #say(message) ⇒ Object
Instance Method Details
#default_options ⇒ Object
4 5 6 |
# File 'lib/trustworthy/cli/command.rb', line 4 def { :config_file => 'trustworthy.yml' } end |
#parse_options(command, args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/trustworthy/cli/command.rb', line 8 def (command, args) = @parser = OptionParser.new do |opts| opts. = "#{Trustworthy::CLI.}\n\nUsage: trustworthy #{command} [options]\n" opts.on('-c', '--config FILE', 'Configuration file to use (default: trustworthy.yml)') do |file| [:config_file] = file end opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end if block_given? yield opts, end end @parser.parse!(args) end |
#print_help ⇒ Object
29 30 31 32 33 |
# File 'lib/trustworthy/cli/command.rb', line 29 def print_help if @parser puts @parser end end |
#say(message) ⇒ Object
35 36 37 |
# File 'lib/trustworthy/cli/command.rb', line 35 def say() $terminal.say() end |