class Goodcheck::Commands::Init

Constants

CONFIG

Attributes

force[R]
path[R]
stderr[R]
stdout[R]

Public Class Methods

new(stdout:, stderr:, path:, force:) click to toggle source
# File lib/goodcheck/commands/init.rb, line 68
def initialize(stdout:, stderr:, path:, force:)
  @stdout = stdout
  @stderr = stderr
  @path = path
  @force = force
end

Public Instance Methods

run() click to toggle source
# File lib/goodcheck/commands/init.rb, line 75
def run
  if path.file? && !force
    stderr.puts "#{path} already exists. Try --force option to overwrite the file."
    return EXIT_ERROR
  end

  path.open("w") do |io|
    io.print(CONFIG)
  end

  stdout.puts "Wrote #{path}. ✍️"

  EXIT_SUCCESS
end