Module: Ronin::Core::CLI::Generator::Options::Author

Defined in:
lib/ronin/core/cli/generator/options/author.rb

Overview

Adds the -a,--author NAME and -e,--author-email EMAIL options for the generator command.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#author_emailString (readonly)

The author email.

Returns:

  • (String)


86
87
88
# File 'lib/ronin/core/cli/generator/options/author.rb', line 86

def author_email
  @author_email
end

#author_nameString (readonly)

The author name.

Returns:

  • (String)


81
82
83
# File 'lib/ronin/core/cli/generator/options/author.rb', line 81

def author_name
  @author_name
end

Class Method Details

.default_emailString?

The default author email.

Returns:

  • (String, nil)


45
46
47
# File 'lib/ronin/core/cli/generator/options/author.rb', line 45

def self.default_email
  Core::Git.user_email
end

.default_nameString?

The default author name.

Returns:

  • (String, nil)


36
37
38
# File 'lib/ronin/core/cli/generator/options/author.rb', line 36

def self.default_name
  Core::Git.user_name || ENV['USERNAME']
end

.included(command) ⇒ Object

Defines the -a,--author NAME and -e,--author-email EMAIL options.

Parameters:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ronin/core/cli/generator/options/author.rb', line 56

def self.included(command)
  command.option :author, short: '-a',
                          value: {
                            type:    String,
                            usage:   'NAME',
                            default: -> { default_name }
                          },
                          desc: 'The name of the author' do |author|
                            @author_name = author
                          end

  command.option :author_email, short: '-e',
                                value: {
                                  type:    String,
                                  usage:   'EMAIL',
                                  default: -> { default_email }
                                },
                                desc: 'The email address of the author' do |email|
                                  @author_email = email
                                end
end

Instance Method Details

#initialize(**kwargs) ⇒ Object

Initializes #author_name and #author_email.

Parameters:

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.



94
95
96
97
98
99
# File 'lib/ronin/core/cli/generator/options/author.rb', line 94

def initialize(**kwargs)
  super(**kwargs)

  @author_name  = Author.default_name
  @author_email = Author.default_email
end