Class: Tetra::InitSubcommand

Inherits:
Subcommand
  • Object
show all
Defined in:
lib/tetra/ui/init_subcommand.rb

Overview

tetra init

Instance Method Summary collapse

Methods inherited from Subcommand

#bypass_parsing, #checking_exceptions, #configure_log_level, #ensure_dry_running, #format_path, #print_generation_result, #verbose=, #very_verbose=, #very_very_verbose=

Methods included from Logging

#log

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tetra/ui/init_subcommand.rb', line 11

def execute
  checking_exceptions do
    if source_archive.nil? && no_archive? == false
      signal_usage_error "please specify a source archive file or use \"--no-archive\" (see SPECIAL_CASES.md)."
    end
    if !source_archive.nil? && !File.readable?(source_archive)
      signal_usage_error "#{source_archive} is not a file or it is not readable."
    end

    Tetra::Project.init(package_name)
    project = Tetra::Project.new(package_name)
    puts "Project inited in #{package_name}/."

    if source_archive
      puts "Decompressing sources..."
      project.commit_source_archive(File.expand_path(source_archive), "Inital sources added from archive")
      puts "Sources decompressed in #{package_name}/src/, original archive copied in #{package_name}/packages/."
    else
      puts "Use \"tetra change-sources\" to add sources to this project."
    end
    puts "Please add any other precompiled build dependency to kit/."
    puts "When you are ready to test a build, use \"tetra dry-run\" from the project directory"
  end
end