Class: Abide::CLI::AbideCommand Abstract

Inherits:
CmdParse::Command
  • Object
show all
Includes:
AbideDevUtils::Config
Defined in:
lib/abide_dev_utils/cli/abstract.rb

Overview

This class is abstract.

Constant Summary

Constants included from AbideDevUtils::Config

AbideDevUtils::Config::DEFAULT_PATH

Instance Method Summary collapse

Methods included from AbideDevUtils::Config

config_section, #config_section, fetch, #fetch, to_h, #to_h

Constructor Details

#initialize(cmd_name, cmd_short, cmd_long, **opts) ⇒ AbideCommand

Returns a new instance of AbideCommand.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/abide_dev_utils/cli/abstract.rb', line 11

def initialize(cmd_name, cmd_short, cmd_long, **opts)
  super(cmd_name, takes_commands: opts.fetch(:takes_commands, false))
  @deprecated = opts.fetch(:deprecated, false)
  if @deprecated
    cmd_short = "[DEPRECATED] #{cmd_short}"
    cmd_long = "[DEPRECATED] #{cmd_long}"
  end
  short_desc(cmd_short)
  long_desc(cmd_long)
  add_command(CmdParse::HelpCommand.new, default: true) if opts[:takes_commands]
end

Instance Method Details

#deprecated?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/abide_dev_utils/cli/abstract.rb', line 30

def deprecated?
  @deprecated
end

#on_after_addObject



23
24
25
26
27
28
# File 'lib/abide_dev_utils/cli/abstract.rb', line 23

def on_after_add
  return unless super_command.respond_to?(:deprecated?) && super_command.deprecated?

  short_desc("[DEPRECATED BY PARENT] #{@short_desc}")
  long_desc("[DEPRECATED BY PARENT] #{@long_desc}")
end