Class: Multisync::Cli

Inherits:
Thor
  • Object
show all
Includes:
Colors, Thor::Actions
Defined in:
lib/multisync/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Colors

#as_fail, #as_main, #as_note, #as_skipped, #as_success

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


9
# File 'lib/multisync/cli.rb', line 9

def self.exit_on_failure? = true

Instance Method Details

#list(*queries) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/multisync/cli.rb', line 22

def list *queries
  queries = ["."] if options[:all]
  tasks = Multisync::Selector.new(catalog, queries).tasks(parents: true)

  puts "Catalog file: #{as_main(options[:catalog])}"
  puts Multisync::List.new(tasks)
end

#start(*queries) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/multisync/cli.rb', line 43

def start *queries
  tasks = Multisync::Selector.new(catalog, queries)
    .tasks
    # only leafs of the task tree can be executed
    .select(&:executeable?)

  # Run
  tasks.each { runtime.run _1 }
rescue Interrupt
  warn as_fail("\nAborted!")
ensure
  # Summarize
  puts Multisync::Summary.new(tasks) if options[:summary] && !options[:print]
end

#versionObject



59
60
61
# File 'lib/multisync/cli.rb', line 59

def version
  puts "multisync v#{Multisync::VERSION}"
end