Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
many: implement our own ANSI-escape-using progress indicator #3964
Merged
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e67a2c0
many: implement our own ANSI-escape-using progress indicator
chipaca 67a6df2
many: add copyright header
chipaca 66bc07a
Merge remote-tracking branch 'upstream/master' into ansimeter
chipaca dd149fd
tweak the Notify line break algo
chipaca abeaf83
Merge branch 'master' into ansimeter
chipaca 2a1bd68
address review feedback
chipaca dd9ac30
Merge branch 'master' into ansimeter
chipaca 06e83b2
add unit tests for ansimeter; some tweaks for quantity corner cases
chipaca
Jump to file or symbol
Failed to load files and symbols.
| @@ -25,7 +25,9 @@ import ( | ||
| "encoding/json" | ||
| "fmt" | ||
| "os" | ||
| + "os/signal" | ||
| "path/filepath" | ||
| + "syscall" | ||
| "github.com/snapcore/snapd/asserts" | ||
| "github.com/snapcore/snapd/asserts/snapasserts" | ||
| @@ -142,11 +144,24 @@ func (tsto *ToolingStore) DownloadSnap(name string, revision snap.Revision, opts | ||
| baseName := filepath.Base(snap.MountFile()) | ||
| targetFn = filepath.Join(targetDir, baseName) | ||
| - pb := progress.NewTextProgress() | ||
| + pb := progress.MakeProgressBar() | ||
| + defer pb.Finished() | ||
| + | ||
| + // Intercept sigint | ||
|
|
||
| + c := make(chan os.Signal, 3) | ||
| + signal.Notify(c, syscall.SIGINT) | ||
| + go func() { | ||
chipaca
Member
|
||
| + <-c | ||
| + pb.Finished() | ||
| + os.Exit(1) | ||
| + }() | ||
| + | ||
| if err = sto.Download(context.TODO(), name, targetFn, &snap.DownloadInfo, pb, tsto.user); err != nil { | ||
| return "", nil, err | ||
| } | ||
| + signal.Reset(syscall.SIGINT) | ||
| + | ||
| return targetFn, snap, nil | ||
| } | ||
Oops, something went wrong.
Thank you!