diff --git a/lib/MPW.rb b/lib/MPW.rb index 791dd3a..f0971cb 100644 --- a/lib/MPW.rb +++ b/lib/MPW.rb @@ -172,7 +172,7 @@ module MPW # @args: file -> file where you export the data # type -> udata type # @rtrn: true if export work - def export(file, type=:csv) + def export(file, type=:yaml) case type when :csv CSV.open(file, 'w', write_headers: true, @@ -200,7 +200,7 @@ module MPW # @args: file -> path to file import # type -> udata type # @rtrn: true if the import work - def import(file, type=:csv) + def import(file, type=:yaml) case type when :csv CSV.foreach(file, {headers: true}) do |row| diff --git a/lib/UI/Cli.rb b/lib/UI/Cli.rb index 59edc54..14b2e97 100644 --- a/lib/UI/Cli.rb +++ b/lib/UI/Cli.rb @@ -307,7 +307,7 @@ class Cli # Export the items in a CSV file # @args: file -> the destination file - def export(file, type) + def export(file, type=:yaml) if @mpw.export(file, type) puts "The export in #{file} is succesfull!" else @@ -319,10 +319,10 @@ class Cli # Import items from a CSV file # @args: file -> the import file # force -> no resquest a validation - def import(file, force=false) + def import(file, type=:yaml, force=false) if not force - result = @mpw.import_preview(file) + result = @mpw.import_preview(file, type) if result.is_a?(Array) and not result.empty? result.each do |r| displayFormat(r) @@ -338,7 +338,7 @@ class Cli end if force - if @mpw.import(file) and @mpw.encrypt + if @mpw.import(file, type) and @mpw.encrypt sync puts I18n.t('form.import.valid') else diff --git a/mpw b/mpw index 309f910..f4092d3 100755 --- a/mpw +++ b/mpw @@ -153,7 +153,7 @@ elsif not options[:export].nil? # Add a new item elsif not options[:import].nil? - cli.import(options[:import], options[:force]) + cli.import(options[:import], options[:type], options[:force]) # Interactive mode else