mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-27 07:33:05 +00:00
fix import and export to yaml
This commit is contained in:
parent
568a8514cf
commit
30f52dfe92
3 changed files with 7 additions and 7 deletions
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
2
mpw
2
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
|
||||
|
|
Loading…
Reference in a new issue