Class: MKBrut::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/mkbrut/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(args:, out: $stdout, err: $stderr) ⇒ CLI

Returns a new instance of CLI.



6
7
8
9
10
# File 'lib/mkbrut/cli.rb', line 6

def initialize(args:, out: $stdout, err: $stderr)
  @args    = args
  @out     = out
  @err     = err
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mkbrut/cli.rb', line 12

def run

  app_options = parse_options(@args, MKBrut::Versions.new)
  new_app = MKBrut::App.new(
    current_dir: Pathname.pwd.expand_path,
    app_options:,
    out: PrefixedIO.new(@out, "mkbrut"),
    err: @err
  )
  new_app.create!
  0
rescue => e
  @err.puts "Error: #{e.message}"
  if ENV["BRUT_CLI_RAISE_ON_ERROR"] == "true"
    raise
  end
  1
end

#show_help(versions) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mkbrut/cli.rb', line 31

def show_help(versions)
  @out.puts @option_parser
  @out.puts
  @out.puts "ARGUMENTS"
  @out.puts
  @out.puts "    app-name - name for your app, which will be the folder where your app's files are created"
  @out.puts
  @out.puts "ENVIRONMENT VARIABLES"
  @out.puts
  @out.puts "  BRUT_CLI_RAISE_ON_ERROR - if set to 'true', any error will raise an exception instead of printing to stderr"
  @out.puts
  @out.puts "BRUT VERSIONS"
  @out.puts
  @out.puts "   Your app will be set up to use these versions:"
  @out.puts
  @out.puts "     BrutRB  - #{versions.brut_version_specifier}"
  @out.puts "     BrutJS  - #{versions.brut_js_version_specifier}"
  @out.puts "     BrutCSS - #{versions.brut_css_version_specifier}"
  @out.puts

end