Module: Kamaze::Project::Concern::Cli

Included in:
WithExitOnFailure
Defined in:
lib/kamaze/project/concern/cli.rb

Overview

Concern for CLI

This module provides base methods focused on retcode.

Defined Under Namespace

Modules: WithExitOnFailure

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/kamaze/project/concern/cli.rb', line 20

def included(base)
  base.class_eval <<-"ACCESSORS", __FILE__, __LINE__ + 1
    protected

    attr_writer :retcode
  ACCESSORS
end

Instance Method Details

#failure?Boolean Also known as: failed?

Denote execution is a failure.

Returns:

  • (Boolean)


46
47
48
# File 'lib/kamaze/project/concern/cli.rb', line 46

def failure?
  !success?
end

#retcodeFixnum

Status code usable to eventually initiates the termination.

Returns:

  • (Fixnum)


32
33
34
# File 'lib/kamaze/project/concern/cli.rb', line 32

def retcode
  @retcode || Errno::NOERROR::Errno
end

#success?Boolean Also known as: successful?

Denote execution is a success.

Returns:

  • (Boolean)


39
40
41
# File 'lib/kamaze/project/concern/cli.rb', line 39

def success?
  Errno::NOERROR::Errno == retcode
end