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

#exportObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cnvrg/cli/flow.rb', line 63

def export()
  if options[:title].blank?
    Cnvrg::CLI.log_message("Flow title is required for export. please use --title='Flow 1'", "red")
    return
  end

  @project = Cnvrg::Project.new(Cnvrg::CLI.get_project_home)
  @flow = Flows.new(options[:title], project: @project)
  filename = @flow.export(options[:version], file: options[:file])
  Cnvrg::CLI.log_message("Flow was saved successfuly to: #{filename}", 'green')
rescue => e
  Cnvrg::CLI.log_message(e.message, 'red')
  Cnvrg::Logger.log_error(e)
end

#importObject



23
24
25
# File 'lib/cnvrg/cli/flow.rb', line 23

def import()
  run_flow_internal(file: options[:file], run: false)
end

#runObject



29
30
31
# File 'lib/cnvrg/cli/flow.rb', line 29

def run()
  run_flow_internal(file: options[:file], run: true)
end