Class: Cnvrg::Commands::Flow

Inherits:
SubCommand show all
Defined in:
lib/cnvrg/cli/flow.rb

Instance Method Summary collapse

Methods inherited from SubCommand

banner, is_thor_reserved_word?, subcommand_prefix

Constructor Details

#initialize(*args) ⇒ Flow

Returns a new instance of Flow.



13
14
15
16
17
18
19
# File 'lib/cnvrg/cli/flow.rb', line 13

def initialize(*args)
  super
  unless @curr_dir.present?
    @cli.log_message("Not On Project Dir, exiting", Thor::Color::RED)
    exit(1)
  end
end

Instance Method Details

#createObject



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cnvrg/cli/flow.rb', line 51

def create
  title = ask("Flow Title: ")
  title = title.presence || "cnvrg-flow"
  relations = []
  task = ask_for_relation
  while task.compact.size == 2
    from, to = task
    relations << {from: from, to: to}
    task = ask_for_relation
  end
  start_commit = ask("Flow Starting Commit (empty will set this value to 'latest')")
  Cnvrg::Flows.create_flow("#{title}.flow.yaml", {title: title, relations: relations, start_commit: start_commit})
end

#run(flow_slug) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cnvrg/cli/flow.rb', line 37

def run(flow_slug)
  unless @curr_dir.present?
    @cli.log_message("Cant run this command because you are not in project directory", Thor::Color::RED)
    return false
  end
  @flow = Cnvrg::Flows.new(flow_slug)
  resp = @flow.run
  flow_version_href = resp["flow_version"]["href"]
  Cnvrg::CLI.log_message("Flow Live results: #{flow_version_href}")
  true
end

#verify(path) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/cnvrg/cli/flow.rb', line 26

def verify(path)
  unless @curr_dir.present?
    @cli.log_message("Cant run this command because you are not in project directory", Thor::Color::RED)
    return false
  end
  @flow = Cnvrg::Flows.new(@curr_dir, path)
  @cli.log_message("The Flow is Valid", Thor::Color::GREEN)
end