From d8181f9926567fd77266f93e3bda70da50c74aa6 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Mon, 27 Jan 2020 14:48:26 +0100 Subject: [PATCH] authd-user-add: compilation fix --- utils/authd-user-add.cr | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/utils/authd-user-add.cr b/utils/authd-user-add.cr index 45f370f..aea38b4 100644 --- a/utils/authd-user-add.cr +++ b/utils/authd-user-add.cr @@ -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} [options]" + if args.size == 0 || args.size > 3 + puts "usage: #{PROGRAM_NAME} [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} [options]" + puts "usage: #{PROGRAM_NAME} [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}"