Class: SubCommand

Inherits:
Thor
  • Object
show all
Defined in:
lib/cnvrg/cli/subcommand.rb

Direct Known Subclasses

Cnvrg::Commands::Flow, Cnvrg::Commands::Task

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ SubCommand

Returns a new instance of SubCommand.



5
6
7
8
9
10
11
# File 'lib/cnvrg/cli/subcommand.rb', line 5

def initialize(*args)
  super
  @cli = Cnvrg::CLI.new
  @curr_dir = @cli.is_cnvrg_dir
  @config = YAML.load_file(@curr_dir + "/.cnvrg/config.yml") if @curr_dir
  @helpers = Cnvrg::OrgHelpers.new();
end

Class Method Details



13
14
15
# File 'lib/cnvrg/cli/subcommand.rb', line 13

def self.banner(command, namespace = nil, subcommand = false)
  "#{basename}  #{command.usage}"
end

.is_thor_reserved_word?(word, type) ⇒ Boolean

Hackery.Take the run method away from Thor so that we can redefine it.

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/cnvrg/cli/subcommand.rb', line 23

def is_thor_reserved_word?(word, type)
  return false if word == "run"
  super
end

.subcommand_prefixObject



17
18
19
# File 'lib/cnvrg/cli/subcommand.rb', line 17

def self.subcommand_prefix
  self.name.gsub(%r{.*::}, '').gsub(%r{^[A-Z]}) {|match| match[0].downcase}.gsub(%r{[A-Z]}) {|match| "-#{match[0].downcase}"}
end