From 3885ca3f06d0b547bbc73d39c4a97d92ecb678f1 Mon Sep 17 00:00:00 2001 From: usiegl00 <50933431+usiegl00@users.noreply.github.com> Date: Tue, 14 Jul 2026 15:57:06 +0900 Subject: [PATCH] Add signup command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds `bld signup -e user@example.com`, a fully CLI-driven signup so an agent can sign a user up on their behalf. It calls the SDK signup endpoint, which sends a verification link to that address; the user then clicks the link and runs `bld login` to authenticate (no auto-login). Output notes that region access is granted separately, so a new account may not have access to any region yet. DefaultApi#signup does not exist in the generated SDK yet — it is added by a follow-up buildio/sdk-crystal-lang PR referencing this one, so this branch does not compile until that SDK update is pinned. Co-Authored-By: Claude Fable 5 --- src/build_cli.cr | 1 + src/commands/signup.cr | 53 ++++++++++++++++++++++++++++++++++++++++++ src/commands/skills.cr | 5 ++++ 3 files changed, 59 insertions(+) create mode 100644 src/commands/signup.cr diff --git a/src/build_cli.cr b/src/build_cli.cr index 84fe1e9..1076859 100644 --- a/src/build_cli.cr +++ b/src/build_cli.cr @@ -65,6 +65,7 @@ application = ACON::Application.new "Build.io CLI", version: VERSION # Register commands using the `#add` method application.add Build::Commands::Whoami.new +application.add Build::Commands::Signup.new application.add Build::Commands::Login.new application.add Build::Commands::OidcLogin.new {% unless flag?(:win32) %} diff --git a/src/commands/signup.cr b/src/commands/signup.cr new file mode 100644 index 0000000..c0d748a --- /dev/null +++ b/src/commands/signup.cr @@ -0,0 +1,53 @@ +require "netrc" + +# This command is used to sign up for a Build account entirely from the CLI, so an +# agent can sign a user up on their behalf with just an email address. It sends the +# email to the Build API, which sends a verification link to that address. Once the +# user clicks the link and finishes creating their account, they can authenticate +# with `bld login`. +# +# NOTE: `DefaultApi#signup` does not exist in the generated SDK yet — it is added +# by a follow-up buildio/sdk-crystal-lang PR, so this file does not compile until +# that SDK update is pinned. +module Build + module Commands + @[ACONA::AsCommand("signup")] + class Signup < Base + protected def configure : Nil + self + .name("signup") + .description("Sign up for a Build account") + .help("This command is used to sign up for a Build account without leaving the terminal. It sends a verification email to the given address. Click the link in the email to finish creating the account, then run `bld login` to authenticate. Note that region access is granted separately, so a newly created account may not have access to any region yet.") + .option("email", "e", :required, "The email address to sign up with.") + .usage("signup -e user@example.com") + end + def execute(input : ACON::Input::Interface, output : ACON::Output::Interface) : ACON::Command::Status + email = input.option("email") + unless email + output.puts " Missing required option --email" + return ACON::Command::Status::FAILURE + end + + begin + # Signup is unauthenticated, so build the client directly instead of + # going through Base#api, which exits when no token is stored. + api_instance = Build::DefaultApi.new + api_instance.signup(email) + rescue e : Build::ApiError + error_message = begin + JSON.parse(e.message.to_s)["error"].to_s + rescue + e.message + end + output.puts("Signup failed: #{error_message}".colorize(:red)) + return ACON::Command::Status::FAILURE + end + + output.puts "Verification email sent to #{email.colorize(:green)}." + output.puts "Click the link in the email to finish creating your account, then run #{"bld login".colorize(:cyan)} to authenticate." + output.puts "Note: region access is granted separately — a new account may not have access to any region yet." + return ACON::Command::Status::SUCCESS + end + end + end +end diff --git a/src/commands/skills.cr b/src/commands/skills.cr index 0a581e4..ba5b70d 100644 --- a/src/commands/skills.cr +++ b/src/commands/skills.cr @@ -74,6 +74,11 @@ module Build --- Authentication --- + bld signup -e user@example.com # Sign up (sends a verification + # email; run `bld login` after). + # Region access is granted + # separately — a new account may + # not have access to any region. bld login # Browser-based OAuth login bld whoami # Show current user