authd-user-add: compilation fix

ipc07
Philippe PITTOLI 2020-01-27 14:48:26 +01:00
parent 10472d5c0d
commit d8181f9926
1 changed files with 14 additions and 6 deletions

View File

@ -6,16 +6,21 @@ key_file : String? = nil
cli_login : String? = nil
profile_file : String? = nil
register = false
email = nil
phone = nil
OptionParser.parse do |parser|
parser.unknown_args do |args|
if args.size != 1
puts "usage: #{PROGRAM_NAME} <login> [options]"
if args.size == 0 || args.size > 3
puts "usage: #{PROGRAM_NAME} <login> <email> <phone> [options]"
puts parser
exit 1
end
cli_login = args[0]
puts "coucou"
pp! args
cli_login, email, phone = args[0..2]
end
parser.on "-p file", "--profile file", "Read the user profile from a file." do |file|
@ -31,7 +36,7 @@ OptionParser.parse do |parser|
end
parser.on "-h", "--help", "Prints this help message." do
puts "usage: #{PROGRAM_NAME} <login> [options]"
puts "usage: #{PROGRAM_NAME} <login> <email> <phone> [options]"
puts parser
exit 0
end
@ -65,15 +70,18 @@ exit 1 unless password
authd = AuthD::Client.new
email = nil if email == ""
phone = nil if phone == ""
begin
if register
authd.register login, password, profile: profile
pp! authd.register login, password, email, phone, profile: profile
else
key_file.try do |file| # FIXME: fail if missing?
authd.key = File.read(file).chomp
end
authd.add_user login, password, profile: profile
pp! authd.add_user login, password, email, phone, profile: profile
end
rescue e : AuthD::Exception
puts "error: #{e.message}"