Skip to content

Commit

Permalink
bib: rename "plain" progress to "verbose" progress
Browse files Browse the repository at this point in the history
This commit renames the "plain" progress to "verbose" progress. The
new name is closer to what the intention of the this progress is
and easier for the users to understand.

Thanks to Ondrej for the suggestion.
  • Loading branch information
mvo5 committed Jan 6, 2025
1 parent 9242b15 commit 425109a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Usage:
Flags:
--chown string chown the ouput directory to match the specified UID:GID
--tls-verify require HTTPS and verify certificates when contacting registries (default true)
--progress string type of progress bar to use (e.g. plain,term)
--progress string type of progress bar to use (e.g. verbose, term)
--type string image type to build [qcow2, ami] (default "qcow2")
--target-arch string architecture to build image for (default is the native architecture)
```
Expand All @@ -138,7 +138,7 @@ Flags:
| Argument | Description | Default Value |
|-------------------|-----------------------------------------------------------------------------------------------------------|:-------------:|
| **--chown** | chown the output directory to match the specified UID:GID ||
| **--progress** | Show progress in the given format, supported: plain,term,debug. If empty it is auto-detected | `auto` |
| **--progress** | Show progress in the given format, supported: verbose,term,debug. If empty it is auto-detected | `auto` |
| **--rootfs** | Root filesystem type. Overrides the default from the source container. Supported values: ext4, xfs, btrfs ||
| **--tls-verify** | Require HTTPS and verify certificates when contacting registries | `true` |
| **--type** | [Image type](#-image-types) to build | `qcow2` |
Expand Down Expand Up @@ -178,11 +178,11 @@ you should provide `--target-arch amd64` when running the `bootc-image-builder`

The following progress types are supported:

* plain: No spinners or progress bar, just information and full osbuild output
* verbose: No spinners or progress bar, just information and full osbuild output
* term: Terminal based output, spinner, progressbar and most details of osbuild are hidden
* debug: Details how the progress is called, mostly useful for bugreports

Note that when no value is given the progress is auto-detected baed on the environment. When `stdin` is a terminal the "term" progress is used, otherwise "plain". The output of `plain` is exactaly the same as it was before progress reporting was implemented.
Note that when no value is given the progress is auto-detected baed on the environment. When `stdin` is a terminal the "term" progress is used, otherwise "verbose". The output of `verbose` is exactaly the same as it was before progress reporting was implemented.

## ☁️ Cloud uploaders

Expand Down
2 changes: 1 addition & 1 deletion bib/cmd/bootc-image-builder/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func uploadAMI(path, targetArch string, flags *pflag.FlagSet) error {
// similar. Eventually we may provide json progress here too.
var pbar *pb.ProgressBar
switch progress {
case "", "plain", "term":
case "auto", "verbose", "term":
pbar = pb.New(0)
}

Expand Down
2 changes: 1 addition & 1 deletion bib/cmd/bootc-image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ func buildCobraCmdline() (*cobra.Command, error) {
buildCmd.Flags().String("output", ".", "artifact output directory")
buildCmd.Flags().String("store", "/store", "osbuild store for intermediate pipeline trees")
//TODO: add json progress for higher level tools like "podman bootc"
buildCmd.Flags().String("progress", "auto", "type of progress bar to use (e.g. plain,term)")
buildCmd.Flags().String("progress", "auto", "type of progress bar to use (e.g. verbose,term)")
// flag rules
for _, dname := range []string{"output", "store", "rpmmd"} {
if err := buildCmd.MarkFlagDirname(dname); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion bib/internal/progress/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
type (
TerminalProgressBar = terminalProgressBar
DebugProgressBar = debugProgressBar
PlainProgressBar = plainProgressBar
VerboseProgressBar = verboseProgressBar
)

func MockOsStderr(w io.Writer) (restore func()) {
Expand Down
26 changes: 13 additions & 13 deletions bib/internal/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func New(typ string) (ProgressBar, error) {
switch typ {
case "auto":
// autoselect based on if we are on an interactive
// terminal, use plain progress for scripts
// terminal, use verbose progress for scripts
if isattyIsTerminal(os.Stdin.Fd()) {
return NewTerminalProgressBar()
}
return NewPlainProgressBar()
case "plain":
return NewPlainProgressBar()
return NewVerboseProgressBar()
case "verbose":
return NewVerboseProgressBar()
case "term":
return NewTerminalProgressBar()
case "debug":
Expand Down Expand Up @@ -241,34 +241,34 @@ func (b *terminalProgressBar) Stop() {
}
}

type plainProgressBar struct {
type verboseProgressBar struct {
w io.Writer
}

// NewPlainProgressBar starts a new "plain" progressbar that will just
// NewVerboseProgressBar starts a new "verbose" progressbar that will just
// prints message but does not show any progress.
func NewPlainProgressBar() (ProgressBar, error) {
b := &plainProgressBar{w: osStderr}
func NewVerboseProgressBar() (ProgressBar, error) {
b := &verboseProgressBar{w: osStderr}
return b, nil
}

func (b *plainProgressBar) SetPulseMsgf(msg string, args ...interface{}) {
func (b *verboseProgressBar) SetPulseMsgf(msg string, args ...interface{}) {
fmt.Fprintf(b.w, msg, args...)
fmt.Fprintf(b.w, "\n")
}

func (b *plainProgressBar) SetMessagef(msg string, args ...interface{}) {
func (b *verboseProgressBar) SetMessagef(msg string, args ...interface{}) {
fmt.Fprintf(b.w, msg, args...)
fmt.Fprintf(b.w, "\n")
}

func (b *plainProgressBar) Start() {
func (b *verboseProgressBar) Start() {
}

func (b *plainProgressBar) Stop() {
func (b *verboseProgressBar) Stop() {
}

func (b *plainProgressBar) SetProgress(subLevel int, msg string, done int, total int) error {
func (b *verboseProgressBar) SetProgress(subLevel int, msg string, done int, total int) error {
return nil
}

Expand Down
10 changes: 5 additions & 5 deletions bib/internal/progress/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestProgressNew(t *testing.T) {
}{
{"term", &progress.TerminalProgressBar{}, ""},
{"debug", &progress.DebugProgressBar{}, ""},
{"plain", &progress.PlainProgressBar{}, ""},
{"verbose", &progress.VerboseProgressBar{}, ""},
// unknown progress type
{"bad", nil, `unknown progress type: "bad"`},
} {
Expand All @@ -33,13 +33,13 @@ func TestProgressNew(t *testing.T) {
}
}

func TestPlainProgress(t *testing.T) {
func TestVerboseProgress(t *testing.T) {
var buf bytes.Buffer
restore := progress.MockOsStderr(&buf)
defer restore()

// plain progress never generates progress output
pbar, err := progress.NewPlainProgressBar()
// verbose progress never generates progress output
pbar, err := progress.NewVerboseProgressBar()
assert.NoError(t, err)
err = pbar.SetProgress(0, "set-progress", 1, 100)
assert.NoError(t, err)
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestProgressNewAutoselect(t *testing.T) {
onTerm bool
expected interface{}
}{
{false, &progress.PlainProgressBar{}},
{false, &progress.VerboseProgressBar{}},
{true, &progress.TerminalProgressBar{}},
} {
restore := progress.MockIsattyIsTerminal(func(uintptr) bool {
Expand Down

0 comments on commit 425109a

Please sign in to comment.