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



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

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)


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

def failure?
  !success?
end

#retcodeFixnum

Status code usable to eventually initiates the termination.

Returns:

  • (Fixnum)


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

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

#success?Boolean Also known as: successful?

Denote execution is a success.

Returns:

  • (Boolean)


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

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