Skip to content

Commit

Permalink
Fix bug with disabling spinner animation
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed May 23, 2023
1 parent 9e09726 commit 9fae6bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ var colorTagApp string
var colorTagVer string

var useRawOutput = false
var noProgress = false

// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down Expand Up @@ -279,6 +280,11 @@ func configureUI() {
progress.DefaultSettings.ProgressColorTag = "{s}"
progress.DefaultSettings.SpeedColorTag = "{s}"
progress.DefaultSettings.RemainingColorTag = "{s}"

if os.Getenv("CI") != "" || options.GetB(OPT_NO_PROGRESS) {
spinner.DisableAnimation = true
noProgress = true
}
}

// prepare do some preparations for installing ruby
Expand Down Expand Up @@ -671,7 +677,7 @@ func installCommand(rubyVersion string) {
spinner.SpinnerColorTag = "{" + categoryColor[category] + "}"
fmtc.NameColor("category", "{"+categoryColor[category]+"}")

if !options.GetB(OPT_NO_PROGRESS) {
if !noProgress {
fmtc.Printf("Fetching {*}{?category}%s{!} from storage…\n", info.Name)
file, err = downloadFile(info)
} else {
Expand All @@ -697,7 +703,7 @@ func installCommand(rubyVersion string) {

// //////////////////////////////////////////////////////////////////////////////// //

if !options.GetB(OPT_NO_PROGRESS) {
if !noProgress {
fmtc.Printf("Unpacking {*}{?category}%s{!} data…\n", info.Name)
err = unpackFile(file, getUnpackDirPath())
} else {
Expand Down Expand Up @@ -1161,7 +1167,7 @@ func downloadFile(info *index.VersionInfo) (string, error) {
return "", fmtc.Errorf("Server return error code %d", resp.StatusCode)
}

if options.GetB(OPT_NO_PROGRESS) {
if noProgress {
_, err = io.Copy(fd, resp.Body)
} else {
pb := progress.New(resp.ContentLength, "")
Expand All @@ -1183,7 +1189,7 @@ func unpackFile(file, outputDir string) error {
return fmt.Errorf("Can't unpack %s: %w", file, err)
}

if options.GetB(OPT_NO_PROGRESS) {
if noProgress {
err = tzst.Read(bufio.NewReader(fd), outputDir)
} else {
pb := progress.New(fsutil.GetSize(file), "")
Expand Down
1 change: 1 addition & 0 deletions common/rbinstall.spec
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ rm -rf %{buildroot}

%changelog
* Tue May 23 2023 Anton Novojilov <[email protected]> - 3.0.4-0
- Fixed bug with disabling spinner animation
- Minor code refactoring

* Thu May 18 2023 Anton Novojilov <[email protected]> - 3.0.3-0
Expand Down

0 comments on commit 9fae6bb

Please sign in to comment.