Module: Warg::Command::BehaviorWithoutRegistration

Included in:
Warg::Command
Defined in:
lib/warg.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



1923
1924
1925
# File 'lib/warg.rb', line 1923

def argv
  @argv
end

#contextObject (readonly)

Returns the value of attribute context.



1924
1925
1926
# File 'lib/warg.rb', line 1924

def context
  @context
end

#hostsObject (readonly)

Returns the value of attribute hosts.



1925
1926
1927
# File 'lib/warg.rb', line 1925

def hosts
  @hosts
end

#operationsObject (readonly)

Returns the value of attribute operations.



1926
1927
1928
# File 'lib/warg.rb', line 1926

def operations
  @operations
end

#parserObject (readonly)

Returns the value of attribute parser.



1927
1928
1929
# File 'lib/warg.rb', line 1927

def parser
  @parser
end

#stepsObject (readonly)

Returns the value of attribute steps.



1928
1929
1930
# File 'lib/warg.rb', line 1928

def steps
  @steps
end

Class Method Details

.included(klass) ⇒ Object



1907
1908
1909
# File 'lib/warg.rb', line 1907

def self.included(klass)
  klass.extend(ClassMethods)
end

Instance Method Details

#callObject



1947
1948
1949
1950
# File 'lib/warg.rb', line 1947

def call
  setup
  self
end

#chain(*others) ⇒ Object



1972
1973
1974
1975
1976
# File 'lib/warg.rb', line 1972

def chain(*others)
  others.inject(self) do |execution, command|
    execution | command
  end
end

#command_nameObject



1964
1965
1966
# File 'lib/warg.rb', line 1964

def command_name
  self.class.command_name
end

#initialize(context) ⇒ Object



1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
# File 'lib/warg.rb', line 1930

def initialize(context)
  @context = context

  @parser = @context.parser
  @hosts = @context.hosts
  @argv = @context.argv.dup

  configure_parser!

  @context.queue!(self)
  @steps = []
end

#nameObject



1943
1944
1945
# File 'lib/warg.rb', line 1943

def name
  command_name.cli
end

#on_failure(execution_result) ⇒ Object



1978
1979
1980
# File 'lib/warg.rb', line 1978

def on_failure(execution_result)
  exit 1
end

#runObject



1955
1956
1957
1958
1959
1960
1961
1962
# File 'lib/warg.rb', line 1955

def run
  Warg.console.puts Console::SGR(command_name.console).with(text_color: :blue, effect: :bold)

  @steps.each do |deferred|
    Warg.console.puts Console::SGR(" -> #{deferred.banner}").with(text_color: :magenta)
    deferred.run
  end
end

#setupObject



1952
1953
# File 'lib/warg.rb', line 1952

def setup
end

#SGR(text) ⇒ Object



1982
1983
1984
# File 'lib/warg.rb', line 1982

def SGR(text)
  Console::SGR(text)
end

#|(other) ⇒ Object



1968
1969
1970
# File 'lib/warg.rb', line 1968

def |(other)
  other.(context)
end