From d87b2deb02b6059482eff6ca196e3807fe5f4ad5 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Fri, 16 Aug 2019 11:38:57 +0200 Subject: [PATCH 1/3] add 'keystore remove' command --- leeloo/lib/leeloo/command.rb | 11 +++++++++++ leeloo/lib/leeloo/preferences.rb | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/leeloo/lib/leeloo/command.rb b/leeloo/lib/leeloo/command.rb index 59f5ec1..8066c27 100644 --- a/leeloo/lib/leeloo/command.rb +++ b/leeloo/lib/leeloo/command.rb @@ -83,6 +83,17 @@ def run end end + command "keystore remove" do |c| + c.syntax = 'leeloo keystore remove ' + c.description = "remove a keystore (path/to/keystore is not destroyed)" + + c.action do |args, options| + abort "name is missing" unless args.length == 1 + @preferences.remove_keystore args.first + OutputFactory.create(options).render_preferences @preferences + end + end + command "keystore add" do |c| c.syntax = 'leeloo keystore add ' c.description = "add a keystore" diff --git a/leeloo/lib/leeloo/preferences.rb b/leeloo/lib/leeloo/preferences.rb index 02fa571..c69031c 100644 --- a/leeloo/lib/leeloo/preferences.rb +++ b/leeloo/lib/leeloo/preferences.rb @@ -32,6 +32,12 @@ def add_keystore keystore @keystores << keystore end end + + def remove_keystore keystore + if @keystores.include? keystore + @keystores.delete keystore + end + end end class PrivateLocalFileSystemPreferences < Preferences From 6b68c8250993bcf4211098d5a0421a9efb3dc735 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Fri, 16 Aug 2019 16:26:48 +0200 Subject: [PATCH 2/3] we update the keystores preference file --- leeloo/lib/leeloo/preferences.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/leeloo/lib/leeloo/preferences.rb b/leeloo/lib/leeloo/preferences.rb index c69031c..0cbcde1 100644 --- a/leeloo/lib/leeloo/preferences.rb +++ b/leeloo/lib/leeloo/preferences.rb @@ -88,6 +88,11 @@ def add_keystore keystore File.write("#{@path}/keystores", @keystores.to_yaml) end + def remove_keystore keystore + super keystore + File.write("#{@path}/keystores", @keystores.to_yaml) + end + end end \ No newline at end of file From fb4f21818e37372f8207eb7f8e0d0b753a4a2324 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sun, 15 Sep 2019 09:50:48 +0200 Subject: [PATCH 3/3] remove a keystore from name --- leeloo/lib/leeloo/preferences.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/leeloo/lib/leeloo/preferences.rb b/leeloo/lib/leeloo/preferences.rb index 0cbcde1..b5975c9 100644 --- a/leeloo/lib/leeloo/preferences.rb +++ b/leeloo/lib/leeloo/preferences.rb @@ -33,8 +33,9 @@ def add_keystore keystore end end - def remove_keystore keystore - if @keystores.include? keystore + def remove_keystore name + keystore = @keystores.find { |k| k["name"] == name } + if keystore !=nil @keystores.delete keystore end end @@ -88,8 +89,8 @@ def add_keystore keystore File.write("#{@path}/keystores", @keystores.to_yaml) end - def remove_keystore keystore - super keystore + def remove_keystore name + super name File.write("#{@path}/keystores", @keystores.to_yaml) end