Class: TRMNLP::Commands::Clone

Inherits:
Base
  • Object
show all
Defined in:
lib/trmnlp/commands/clone.rb

Defined Under Namespace

Classes: Options

Instance Method Summary collapse

Methods inherited from Base

#initialize, options_from, run

Constructor Details

This class inherits a constructor from TRMNLP::Commands::Base

Instance Method Details

#call(directory_name, id) ⇒ Object

Raises:



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

def call(directory_name, id)
  authenticate!

  destination_path = Pathname.new(options.dir).join(directory_name)
  raise DirectoryExists, "directory #{destination_path} already exists, aborting" if destination_path.exist?

  Init.run({ dir: options.dir, skip_liquid: true, quiet: true, skip_git: options.skip_git }, directory_name)

  Pull.run({ dir: destination_path.to_s, force: true, id: id })

  reporter.info <<~HEREDOC

    To start the local server:

        cd #{Pathname.new(destination_path).relative_path_from(Dir.pwd)} && trmnlp serve
  HEREDOC
end