Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Subcommands:
unpublish Make a commit private`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
// Bare `vers commit` with no args create commit of HEAD
// Bare `vers commit` with no args -> create commit of HEAD
return commitCreateCmd.RunE(cmd, args)
},
}
Expand Down Expand Up @@ -68,7 +68,7 @@ Use --format json for machine-readable output.`,
if res.UsedHEAD {
fmt.Printf("Using current HEAD VM: %s\n", res.VmID)
}
fmt.Printf("Committed VM '%s'\n", res.VmID)
fmt.Printf("Committed VM '%s'\n", res.VmID)
fmt.Printf("Commit ID: %s\n", res.CommitID)
}
return nil
Expand Down Expand Up @@ -139,13 +139,13 @@ Examples:
CommitID: id,
})
if err != nil {
fmt.Fprintf(cmd.ErrOrStderr(), "✗ Failed to delete commit %s: %v\n", id, err)
fmt.Fprintf(cmd.ErrOrStderr(), "error: failed to delete commit %s: %v\n", id, err)
if firstErr == nil {
firstErr = err
}
continue
}
fmt.Printf("Commit %s deleted\n", id)
fmt.Printf("Commit %s deleted\n", id)
}
return firstErr
},
Expand Down Expand Up @@ -198,7 +198,7 @@ var commitPublishCmd = &cobra.Command{
if err != nil {
return err
}
fmt.Printf("Commit %s is now public\n", info.CommitID)
fmt.Printf("Commit %s is now public\n", info.CommitID)
return nil
},
}
Expand All @@ -219,7 +219,7 @@ var commitUnpublishCmd = &cobra.Command{
if err != nil {
return err
}
fmt.Printf("Commit %s is now private\n", info.CommitID)
fmt.Printf("Commit %s is now private\n", info.CommitID)
return nil
},
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (

// TestExecuteCommandArgumentParsing tests the argument parsing logic for execute.
// The logic uses LooksLikeVMTarget to decide if the first arg is a VM or a command:
// - UUID treated as VM target
// - Known alias treated as VM target
// - Anything else treated as command, uses HEAD
// - UUID -> treated as VM target
// - Known alias -> treated as VM target
// - Anything else -> treated as command, uses HEAD
func TestExecuteCommandArgumentParsing(t *testing.T) {
tests := []struct {
name string
Expand Down
20 changes: 10 additions & 10 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func loginWithGit() error {
fmt.Print("Looking up git email... ")
email, err := auth.GetGitEmail()
if err != nil {
fmt.Println("")
fmt.Println("failed")
return err
}
fmt.Println(email)
Expand All @@ -93,7 +93,7 @@ func loginWithGit() error {
fmt.Print("Looking up SSH public key... ")
sshPubKey, _, err := auth.FindSSHPublicKey()
if err != nil {
fmt.Println("")
fmt.Println("failed")
return err
}
// Show truncated key for confirmation
Expand All @@ -116,7 +116,7 @@ func loginWithGit() error {

if initResp.AlreadyVerified {
// Key is already verified — skip email, go straight to verify-key for org list
fmt.Println("SSH key already verified")
fmt.Println("SSH key already verified")
verifyResp, err = auth.ShellAuthCheckVerification(email, sshPubKey)
if err != nil {
return fmt.Errorf("failed to fetch org list: %w", err)
Expand All @@ -127,16 +127,16 @@ func loginWithGit() error {
}

// Step 4: Wait for email verification
fmt.Printf("\n📧 Verification email sent to %s\n", email)
fmt.Printf("\nVerification email sent to %s\n", email)
fmt.Println(" Click the link in the email to continue.")
fmt.Print(" Waiting for verification...")

verifyResp, err = auth.ShellAuthPollVerification(email, sshPubKey, 10*time.Minute)
if err != nil {
fmt.Println(" ")
fmt.Println(" failed")
return err
}
fmt.Println(" ")
fmt.Println(" ok")
}

// Step 5: Select organization
Expand Down Expand Up @@ -176,23 +176,23 @@ func loginWithGit() error {
fmt.Print("Creating API key... ")
keyResp, err := auth.ShellAuthCreateAPIKey(email, sshPubKey, label, orgName)
if err != nil {
fmt.Println("")
fmt.Println("failed")
return fmt.Errorf("failed to create API key: %w", err)
}
fmt.Println("")
fmt.Println("ok")

// Step 7: Validate and save
fmt.Print("Validating API key... ")
if err := validateAPIKey(keyResp.APIKey); err != nil {
fmt.Println("")
fmt.Println("failed")
return err
}

if err := auth.SaveAPIKey(keyResp.APIKey); err != nil {
return fmt.Errorf("error saving API key: %w", err)
}

fmt.Printf("\n✓ Successfully authenticated with Vers (org: %s)\n", keyResp.OrgName)
fmt.Printf("\nSuccessfully authenticated with Vers (org: %s)\n", keyResp.OrgName)
return nil
}

Expand Down
18 changes: 9 additions & 9 deletions cmd/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var repoCreateCmd = &cobra.Command{
if err != nil {
return err
}
fmt.Printf("Repository '%s' created (%s)\n", resp.Name, resp.RepoID)
fmt.Printf("Repository '%s' created (%s)\n", resp.Name, resp.RepoID)
return nil
},
}
Expand Down Expand Up @@ -138,13 +138,13 @@ Examples:
Name: name,
})
if err != nil {
fmt.Fprintf(cmd.ErrOrStderr(), "✗ Failed to delete repository '%s': %v\n", name, err)
fmt.Fprintf(cmd.ErrOrStderr(), "error: failed to delete repository '%s': %v\n", name, err)
if firstErr == nil {
firstErr = err
}
continue
}
fmt.Printf("Repository '%s' deleted\n", name)
fmt.Printf("Repository '%s' deleted\n", name)
}
return firstErr
},
Expand Down Expand Up @@ -179,7 +179,7 @@ Examples:
if repoVisibilityPublic {
vis = "public"
}
fmt.Printf("Repository '%s' is now %s\n", args[0], vis)
fmt.Printf("Repository '%s' is now %s\n", args[0], vis)
return nil
},
}
Expand Down Expand Up @@ -220,7 +220,7 @@ Examples:
if err != nil {
return err
}
fmt.Printf("Forked %s\n", resp.Reference)
fmt.Printf("Forked -> %s\n", resp.Reference)
fmt.Printf(" VM: %s\n", resp.VmID)
fmt.Printf(" Commit: %s\n", resp.CommitID)
return nil
Expand Down Expand Up @@ -255,7 +255,7 @@ var repoTagCreateCmd = &cobra.Command{
if err != nil {
return err
}
fmt.Printf("Tag created %s\n", resp.Reference)
fmt.Printf("Tag created -> %s\n", resp.Reference)
return nil
},
}
Expand Down Expand Up @@ -362,7 +362,7 @@ var repoTagUpdateCmd = &cobra.Command{
if err != nil {
return err
}
fmt.Printf("Tag '%s' in '%s' updated\n", args[1], args[0])
fmt.Printf("Tag '%s' in '%s' updated\n", args[1], args[0])
return nil
},
}
Expand Down Expand Up @@ -390,13 +390,13 @@ Examples:
TagName: name,
})
if err != nil {
fmt.Fprintf(cmd.ErrOrStderr(), "✗ Failed to delete tag '%s': %v\n", name, err)
fmt.Fprintf(cmd.ErrOrStderr(), "error: failed to delete tag '%s': %v\n", name, err)
if firstErr == nil {
firstErr = err
}
continue
}
fmt.Printf("Tag '%s' deleted from '%s'\n", name, repoName)
fmt.Printf("Tag '%s' deleted from '%s'\n", name, repoName)
}
return firstErr
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Use --format json for machine-readable output.`,
case pres.FormatJSON:
pres.PrintJSON(map[string]interface{}{"vm_id": vmID, "fs_size_mib": resizeDiskSize})
default:
fmt.Printf("Disk resized to %d MiB for VM %s\n", resizeDiskSize, vmID)
fmt.Printf("Disk resized to %d MiB for VM %s\n", resizeDiskSize, vmID)
}
return nil
},
Expand Down
22 changes: 11 additions & 11 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@ interaction capabilities, and more.`,
cmd.CalledAs() == "help" ||
cmd.Name() == "upgrade"

if !skipUpdateCheck {
// Synchronous update check with a tight timeout. Uses a
// disk-cached "latest known release" so the nag prints
// instantly on subsequent runs without any network I/O,
// and only refreshes once per check interval.
//
// Done synchronously (not in a goroutine) because short
// commands like `vers ps` would exit before a detached
// goroutine could finish its HTTP call, suppressing the
// nag indefinitely.
update.MaybeNotifyUpdate(cmd.Context(), Version, Repository, 800*time.Millisecond, verbose)
if !skipUpdateCheck && update.ShouldCheckForUpdate() {
// Update the check time regardless of result
update.UpdateCheckTime()
// Check for updates in background
go func() {
DebugPrint("Checking for updates...\n")
hasUpdate, latestVersion, err := update.CheckForUpdates(Version, Repository, verbose)
if err == nil && hasUpdate {
fmt.Printf("note: update available: %s -> %s (run 'vers upgrade')\n\n", Version, latestVersion)
}
}()
}

if cmd.Name() == "login" || cmd.Name() == "signup" || cmd.Name() == "help" || cmd.CalledAs() == "help" {
Expand Down
26 changes: 13 additions & 13 deletions cmd/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func signupWithGit() error {
var err error
email, err = auth.GetGitEmail()
if err != nil {
fmt.Println("")
fmt.Println("failed")
return err
}
fmt.Println(email)
Expand All @@ -38,7 +38,7 @@ func signupWithGit() error {
fmt.Print("Looking up SSH public key... ")
sshPubKey, sshKeyPath, err := auth.FindSSHPublicKey()
if err != nil {
fmt.Println("")
fmt.Println("failed")
return err
}
// Show truncated key for confirmation
Expand All @@ -61,7 +61,7 @@ func signupWithGit() error {

if initResp.AlreadyVerified {
// Key is already verified — skip email, go straight to verify-key for org list
fmt.Println("SSH key already verified")
fmt.Println("SSH key already verified")
verifyResp, err = auth.ShellAuthCheckVerification(email, sshPubKey)
if err != nil {
return fmt.Errorf("failed to fetch org list: %w", err)
Expand All @@ -72,16 +72,16 @@ func signupWithGit() error {
}

// Step 4: Wait for email verification
fmt.Printf("\n📧 Verification email sent to %s\n", email)
fmt.Printf("\nVerification email sent to %s\n", email)
fmt.Println(" Click the link in the email to continue.")
fmt.Print(" Waiting for verification...")

verifyResp, err = auth.ShellAuthPollVerification(email, sshPubKey, 10*time.Minute)
if err != nil {
fmt.Println(" ")
fmt.Println(" failed")
return err
}
fmt.Println(" ")
fmt.Println(" ok")
}

// Step 5: Select organization
Expand Down Expand Up @@ -127,15 +127,15 @@ func signupWithGit() error {
fmt.Print("Creating API key... ")
keyResp, err := auth.ShellAuthCreateAPIKey(email, sshPubKey, label, orgName)
if err != nil {
fmt.Println("")
fmt.Println("failed")
return fmt.Errorf("failed to create API key: %w", err)
}
fmt.Println("")
fmt.Println("ok")

// Step 7: Validate and save
fmt.Print("Validating API key... ")
if err := validateAPIKey(keyResp.APIKey); err != nil {
fmt.Println("")
fmt.Println("failed")
return err
}

Expand All @@ -150,7 +150,7 @@ func signupWithGit() error {
return fmt.Errorf("error saving config: %w", err)
}

fmt.Printf("\n✓ Successfully authenticated with Vers (org: %s)\n", keyResp.OrgName)
fmt.Printf("\nSuccessfully authenticated with Vers (org: %s)\n", keyResp.OrgName)
return nil
}

Expand Down Expand Up @@ -181,16 +181,16 @@ If you already have an account, this will log you in.`,

fmt.Print("Validating API key... ")
if err := validateAPIKey(apiKey); err != nil {
fmt.Println("")
fmt.Println("failed")
return err
}
fmt.Println("")
fmt.Println("ok")

if err := auth.SaveAPIKey(apiKey); err != nil {
return fmt.Errorf("error saving API key: %w", err)
}

fmt.Println("\n✓ Successfully authenticated with Vers")
fmt.Println("\nSuccessfully authenticated with Vers")
return nil
},
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var tagCreateCmd = &cobra.Command{
if err != nil {
return err
}
fmt.Printf("Tag '%s' created %s\n", resp.TagName, resp.CommitID)
fmt.Printf("Tag '%s' created -> %s\n", resp.TagName, resp.CommitID)
return nil
},
}
Expand Down Expand Up @@ -138,7 +138,7 @@ var tagUpdateCmd = &cobra.Command{
if err != nil {
return err
}
fmt.Printf("Tag '%s' updated\n", args[0])
fmt.Printf("Tag '%s' updated\n", args[0])
return nil
},
}
Expand All @@ -163,13 +163,13 @@ Examples:
TagName: name,
})
if err != nil {
fmt.Fprintf(cmd.ErrOrStderr(), "✗ Failed to delete tag '%s': %v\n", name, err)
fmt.Fprintf(cmd.ErrOrStderr(), "error: failed to delete tag '%s': %v\n", name, err)
if firstErr == nil {
firstErr = err
}
continue
}
fmt.Printf("Tag '%s' deleted\n", name)
fmt.Printf("Tag '%s' deleted\n", name)
}
return firstErr
},
Expand Down
2 changes: 1 addition & 1 deletion internal/auth/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ func GetOrCreateSSHKey(vmID string, client *vers.Client, apiCtx context.Context)
return "", fmt.Errorf("failed to save SSH key: %w", err)
}

fmt.Println("SSH key cached")
fmt.Println("SSH key cached")
return keyPath, nil
}
Loading
Loading