Skip to content

Commit

Permalink
Merge pull request #11 from sylvek/feature/remove-a-keystore
Browse files Browse the repository at this point in the history
add 'keystore remove' command
  • Loading branch information
sylvek committed Sep 15, 2019
2 parents ce944d4 + fb4f218 commit b122e44
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions leeloo/lib/leeloo/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ def run
end
end

command "keystore remove" do |c|
c.syntax = 'leeloo keystore remove <name>'
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 <name> <path/to/keystore>'
c.description = "add a keystore"
Expand Down
12 changes: 12 additions & 0 deletions leeloo/lib/leeloo/preferences.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ def add_keystore keystore
@keystores << keystore
end
end

def remove_keystore name
keystore = @keystores.find { |k| k["name"] == name }
if keystore !=nil
@keystores.delete keystore
end
end
end

class PrivateLocalFileSystemPreferences < Preferences
Expand Down Expand Up @@ -82,6 +89,11 @@ def add_keystore keystore
File.write("#{@path}/keystores", @keystores.to_yaml)
end

def remove_keystore name
super name
File.write("#{@path}/keystores", @keystores.to_yaml)
end

end

end

0 comments on commit b122e44

Please sign in to comment.