class Hbtrack::ImportCommand
ImportCommand
class is responsible for handling `hbtrack import` command in CLI
Public Class Methods
new(store_path, options)
click to toggle source
Calls superclass method
Hbtrack::Command::new
# File lib/hbtrack/command/import_command.rb, line 14 def initialize(store_path, options) @importer = Hbtrack::Importer::HbtrackImporter.new super(store_path, options) end
Public Instance Methods
create_option_parser()
click to toggle source
# File lib/hbtrack/command/import_command.rb, line 24 def create_option_parser OptionParser.new do |opts| opts.banner = 'Usage: hbtrack import <file_path> <options>' opts.on('--streaks', 'Import data from streaks') do @importer = Hbtrack::Importer::StreaksImporter.new end end end
execute()
click to toggle source
Calls superclass method
Hbtrack::Command#execute
# File lib/hbtrack/command/import_command.rb, line 19 def execute return import(@names[0]) super end
import(file_path)
click to toggle source
# File lib/hbtrack/command/import_command.rb, line 33 def import(file_path) @importer.import_from(file_path) @importer.store_in(local_store) Hbtrack::Util.green "Succesfully imported from #{file_path}" rescue => e Hbtrack::Util.red "Error: #{e}" end