Skip to content

Commit

Permalink
add insert/generate/init/rm password store commands compatibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Maucourt committed Feb 18, 2022
1 parent c97d0ab commit fd13330
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
41 changes: 32 additions & 9 deletions leeloo/lib/leeloo/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def run
end
end

command :init do |c|
c.syntax = 'leeloo init'
c.description = "Just to be compatible with passwordstore.org"
end

command :list do |c|
c.syntax = 'leeloo list [options]'
c.description = "Display secrets list of stored on a keystore"
Expand Down Expand Up @@ -79,7 +84,7 @@ def run
end
end

command "keystore remove" do |c|
command :"keystore remove" do |c|
c.syntax = 'leeloo keystore remove <name>'
c.description = "remove a keystore (path/to/keystore is not destroyed)"

Expand All @@ -92,7 +97,7 @@ def run
end
end

command "keystore add" do |c|
command :"keystore add" do |c|
c.syntax = 'leeloo keystore add <name> <path/to/keystore>'
c.description = "add a keystore"

Expand All @@ -106,7 +111,7 @@ def run
end
end

command "keystore default" do |c|
command :"keystore default" do |c|
c.syntax = 'leeloo keystore default name'
c.description = "set the default keystore"

Expand All @@ -131,7 +136,7 @@ def run
end
end

command "key sync" do |c|
command :"key sync" do |c|
c.syntax = 'leeloo keys sync'
c.description = "synchronize secrets with keys"
c.option '--keystore STRING', String, 'a selected keystore'
Expand All @@ -143,7 +148,7 @@ def run
end
end

command "key add" do |c|
command :"key add" do |c|
c.syntax = 'leeloo key add <email>'
c.description = "add a dedicated key"
c.option '--keystore STRING', String, 'a selected keystore'
Expand All @@ -157,7 +162,7 @@ def run
end
end

command "key remove" do |c|
command :"key remove" do |c|
c.syntax = 'leeloo key remove <email>'
c.description = "remove a dedicated key"
c.option '--keystore STRING', String, 'a selected keystore'
Expand Down Expand Up @@ -202,6 +207,23 @@ def run
ctl.display
end
end
alias_command :insert, :write

command :generate do |c|
c.syntax = 'leeloo generate <name> <number of randomized characters>'
c.description = "Generate a secret from a keystore"
c.option '--keystore STRING', String, 'a selected keystore'
c.option '--clipboard', nil, 'copy to clipboard'

c.action do |args, options|
abort "name or number are missing" unless args.length == 2
name = args.first
options.__hash__[:generate] = args.last.to_i
ctl = SecretController.new(options)
ctl.write(name)
ctl.display
end
end

command :translate do |c|
c.syntax = 'leeloo translate'
Expand Down Expand Up @@ -229,8 +251,9 @@ def run
puts "done."
end
end
alias_command :rm, :remove

command "keystore sync" do |c|
command :"keystore sync" do |c|
c.syntax = 'leeloo sync'
c.description = "Synchronize a keystore"
c.option '--keystore STRING', String, 'a selected keystore'
Expand All @@ -242,7 +265,7 @@ def run
end
end

command "keystore export" do |c|
command :"keystore export" do |c|
c.syntax = 'leeloo export'
c.description = "Export all secrets from a keystore"
c.option '--keystore STRING', String, 'a selected keystore'
Expand All @@ -253,7 +276,7 @@ def run
end
end

command "keystore init" do |c|
command :"keystore init" do |c|
c.syntax = 'leeloo init'
c.description = "Initialize a keystore"
c.option '--keystore STRING', String, 'a selected keystore'
Expand Down
4 changes: 2 additions & 2 deletions leeloo/lib/leeloo/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def write name
phrase = SecureRandom.base64(32).truncate(@options.generate.to_i) if @options.generate

unless phrase
phrase = password "secret"
confirm = password "confirm it"
phrase = password "Enter password for #{name}"
confirm = password "Confirm it"
abort "not the same secret" unless phrase == confirm
end

Expand Down
1 change: 1 addition & 0 deletions leeloo/lib/leeloo/keystore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class PrivateLocalFileSystemKeystore < Keystore
def initialize name, path
super name
@path = path
FileUtils.touch "#{@path}/.gpg-id"
FileUtils.mkdir_p "#{@path}/secrets"
end

Expand Down
2 changes: 1 addition & 1 deletion leeloo/lib/leeloo/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Leeloo
VERSION = '0.5.1'.freeze
VERSION = '0.5.2'.freeze
DESCRIPTION = "The easiest way to share securely your secrets".freeze
end

0 comments on commit fd13330

Please sign in to comment.