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.



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

def argv
  @argv
end

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#hostsObject (readonly)

Returns the value of attribute hosts.



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

def hosts
  @hosts
end

#operationsObject (readonly)

Returns the value of attribute operations.



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

def operations
  @operations
end

#parserObject (readonly)

Returns the value of attribute parser.



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

def parser
  @parser
end

#stepsObject (readonly)

Returns the value of attribute steps.



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

def steps
  @steps
end

Class Method Details

.included(klass) ⇒ Object



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

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

Instance Method Details

#callObject



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

def call
  setup
  self
end

#chain(*others) ⇒ Object



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

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

#command_nameObject



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

def command_name
  self.class.command_name
end

#initialize(context) ⇒ Object



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

def initialize(context)
  @context = context

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

  configure_parser!

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

#nameObject



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

def name
  command_name.cli
end

#on_failure(execution_result) ⇒ Object



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

def on_failure(execution_result)
  exit 1
end

#runObject



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

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



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

def setup
end

#SGR(text) ⇒ Object



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

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

#|(other) ⇒ Object



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

def |(other)
  other.(context)
end