Skip to content

Commit a1d3d1e

Browse files
committed
Improve CLI usability and improve automation cases (e.g. LLMs)
- Migrated from Cobra to Kong framework - Improved help text for better readability by humans and LLMs - Dynamic shell completions with comprehensive flag and subcommand suggestions - Better error messages - Various improvements to make things more LLM friendly: - Non-interactive modes for `bk build watch` - Add `bk job logs <job-id>`` command for viewing individual job logs - Add `--logs` and `--failed-only` flags to `bk build download` command - New `--output` flag for all data query commands (deprecated `--json`) See UPGRADING.md for breaking changes and upgrade instructions.
1 parent bd8d627 commit a1d3d1e

File tree

172 files changed

+3897
-1623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+3897
-1623
lines changed

AGENT.md

Lines changed: 9 additions & 1 deletion

README.md

Lines changed: 97 additions & 25 deletions

UPGRADING.md

Lines changed: 12 additions & 0 deletions

main renamed to bk

28.4 MB
Binary file not shown.

cli

-1.91 KB
Binary file not shown.

cmd/bk/main.go

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package main
22

33
import (
4-
"context"
54
"os"
65

76
bkErrors "github.com/buildkite/cli/v3/internal/errors"
87
"github.com/buildkite/cli/v3/internal/version"
8+
"github.com/buildkite/cli/v3/pkg/cli"
99
"github.com/buildkite/cli/v3/pkg/cmd/factory"
10-
"github.com/buildkite/cli/v3/pkg/cmd/root"
1110
)
1211

1312
func main() {
@@ -16,8 +15,6 @@ func main() {
1615
}
1716

1817
func mainRun() int {
19-
ctx := context.Background()
20-
2118
// Create factory
2219
f, err := factory.New(version.Version)
2320
if err != nil {
@@ -31,37 +28,6 @@ func mainRun() int {
3128
return bkErrors.ExitCodeInternalError
3229
}
3330

34-
// Create root command
35-
rootCmd, err := root.NewCmdRoot(f)
36-
if err != nil {
37-
errHandler := bkErrors.NewHandler()
38-
errHandler.Handle(bkErrors.NewInternalError(
39-
err,
40-
"failed to create command structure",
41-
"This is likely a bug in the CLI",
42-
"Please report this issue to the Buildkite CLI team",
43-
))
44-
return bkErrors.ExitCodeInternalError
45-
}
46-
47-
// Set context
48-
rootCmd.SetContext(ctx)
49-
50-
// Get verbose flag value
51-
verbose, _ := rootCmd.PersistentFlags().GetBool("verbose")
52-
53-
// Silence Cobra's error printing so we can handle it ourselves
54-
rootCmd.SilenceErrors = true
55-
56-
// Execute the command
57-
err = rootCmd.Execute()
58-
if err != nil {
59-
// Handle the error with our error handler
60-
errHandler := bkErrors.NewHandler().WithVerbose(verbose)
61-
errHandler.HandleWithDetails(err, rootCmd.CommandPath())
62-
return bkErrors.GetExitCodeForError(err)
63-
}
64-
65-
// If we get here, the command executed successfully
66-
return bkErrors.ExitCodeSuccess
31+
// Use Kong CLI
32+
return cli.Run(version.Version, f)
6733
}

cmd/bk/main.go.tmp

Whitespace-only changes.

generate.go.tmp

Whitespace-only changes.

genqlient.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ bindings:
1313
type: string
1414
YAML:
1515
type: string
16+
DateTime:
17+
type: string

go.mod

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ toolchain go1.24.1
77
require (
88
github.com/AlecAivazis/survey/v2 v2.3.7
99
github.com/MakeNowJust/heredoc v1.0.0
10+
github.com/alecthomas/kong v1.12.0
1011
github.com/buildkite/go-buildkite/v4 v4.1.0
1112
github.com/charmbracelet/bubbles v0.21.0
1213
github.com/charmbracelet/bubbletea v1.3.5
@@ -18,9 +19,11 @@ require (
1819
github.com/go-git/go-git/v5 v5.16.2
1920
github.com/muesli/reflow v0.3.0
2021
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
22+
github.com/posener/complete v1.2.3
2123
github.com/spf13/cobra v1.9.1
2224
github.com/spf13/viper v1.20.1
2325
github.com/vektah/gqlparser/v2 v2.5.30
26+
github.com/willabides/kongplete v0.4.0
2427
github.com/xeipuuv/gojsonschema v1.2.0
2528
golang.org/x/sync v0.16.0
2629
gopkg.in/yaml.v3 v3.0.1
@@ -46,8 +49,11 @@ require (
4649
github.com/go-viper/mapstructure/v2 v2.3.0 // indirect
4750
github.com/google/uuid v1.6.0 // indirect
4851
github.com/gorilla/css v1.0.1 // indirect
52+
github.com/hashicorp/errwrap v1.1.0 // indirect
53+
github.com/hashicorp/go-multierror v1.1.1 // indirect
4954
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
5055
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
56+
github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab // indirect
5157
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
5258
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
5359
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect

0 commit comments

Comments
 (0)