Class: Cnvrg::Commands::Flow
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
#create ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/cnvrg/cli/flow.rb', line 58
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(path) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/cnvrg/cli/flow.rb', line 38
def run(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
begin
@flow = Cnvrg::Flows.new(@curr_dir, path)
url = @flow.run
rescue => e
@cli.log_message("Cant run the flow, please run 'cnvrg flow verify #{path}' to check it", Thor::Color::RED)
@cli.log_error(e)
return
end
check = Cnvrg::Helpers.checkmark
@cli.log_message("#{check} The flow is running, you can track the status in: #{url}", Thor::Color::GREEN)
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
|