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