Class: Daygram::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions, ThorPlus::Actions
Defined in:
lib/daygram/cli.rb

Overview

The Command Line Interface (CLI) for the gem.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ CLI

Returns a new instance of CLI.



65
66
67
# File 'lib/daygram/cli.rb', line 65

def initialize args = [], options = {}, config = {}
  super args, options, config
end

Class Method Details

.configurationObject



61
62
63
# File 'lib/daygram/cli.rb', line 61

def self.configuration
  Runcom::Configuration.new file_name: Daygram::Identity.file_name
end

Instance Method Details

#configObject



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/daygram/cli.rb', line 82

def config
  path = self.class.configuration.computed_path

  unless File.exists? path
    FileUtils.touch(path)
  end

  if options.edit? then `#{editor} #{path}`
  elsif options.info? then say(path)
  else help(:config)
  end
end

#help(task = nil) ⇒ Object



103
104
105
# File 'lib/daygram/cli.rb', line 103

def help task = nil
  say and super
end

#versionObject



97
98
99
# File 'lib/daygram/cli.rb', line 97

def version
  say Identity.version_label
end