add option show all
This commit is contained in:
parent
eacca141d9
commit
297b464a24
1 changed files with 23 additions and 4 deletions
|
@ -98,8 +98,8 @@ class ManagePasswd
|
||||||
result = Array.new()
|
result = Array.new()
|
||||||
@data.lines do |line|
|
@data.lines do |line|
|
||||||
row = line.parse_csv
|
row = line.parse_csv
|
||||||
if line =~ /^.*#{search}.*$/
|
if line =~ /^.*#{search}.*$/ || type.eql?('all')
|
||||||
if type.nil? || type.eql?(row[TYPE])
|
if type.nil? || type.eql?(row[TYPE]) || type.eql?('all')
|
||||||
result.push(row)
|
result.push(row)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -246,8 +246,13 @@ options = {}
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: manage-password.rb [options]"
|
opts.banner = "Usage: manage-password.rb [options]"
|
||||||
|
|
||||||
opts.on("-d", "--display SEARCH", "Display items") do |search|
|
opts.on("-d", "--display [SEARCH]", "Display items") do |search|
|
||||||
options[:display] = search
|
search.nil? ? (options[:display] = '') : (options[:display] = search)
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("-A", "--show-all", "Show all items") do |b|
|
||||||
|
options[:showall] = true
|
||||||
|
options[:display] = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("-u", "--update ID", "Update an items") do |id|
|
opts.on("-u", "--update ID", "Update an items") do |id|
|
||||||
|
@ -262,16 +267,30 @@ OptionParser.new do |opts|
|
||||||
options[:add] = true
|
options[:add] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("-t", "--type TYPE", "select an type") do |type|
|
||||||
|
options[:type] = type
|
||||||
|
end
|
||||||
|
|
||||||
opts.on("-h", "--help", "Show this message") do |b|
|
opts.on("-h", "--help", "Show this message") do |b|
|
||||||
puts opts
|
puts opts
|
||||||
|
exit 0
|
||||||
end
|
end
|
||||||
end.parse!
|
end.parse!
|
||||||
|
|
||||||
manage = ManagePasswd.new(KEY, FILE_GPG, FILE_PWD)
|
manage = ManagePasswd.new(KEY, FILE_GPG, FILE_PWD)
|
||||||
|
|
||||||
# Display the item's informations
|
# Display the item's informations
|
||||||
|
puts options
|
||||||
if not options[:display].nil?
|
if not options[:display].nil?
|
||||||
|
puts "test"
|
||||||
|
if not options[:type].nil?
|
||||||
|
manage.display(options[:display], options[:type])
|
||||||
|
elsif not options[:showall].nil?
|
||||||
|
puts "test"
|
||||||
|
manage.display(options[:display], 'all')
|
||||||
|
else
|
||||||
manage.display(options[:display])
|
manage.display(options[:display])
|
||||||
|
end
|
||||||
|
|
||||||
# Remove an item
|
# Remove an item
|
||||||
elsif not options[:remove].nil?
|
elsif not options[:remove].nil?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue