Exemple #1
0
func install(l, version string) error {
	var currentStep lang.Step
	var bar *pb.ProgressBar
	var process *Process
	fmt.Printf("Installing %s@%s\n", l, version)
	err := service.Install(l, version, binaryFlag, func(step lang.Step, progress, total int64) {

		if currentStep != step {
			if bar != nil {
				bar.NotPrint = true
				bar.Finish()
				fmt.Printf(ascii2.EraseLine)
				bar = nil
			}

			if process != nil {
				process.Done("")
				process = nil
			}

			if total > 0 {
				bar = pb.New64(total).Prefix("  " + stepToMsg(step) + "\t\t")
				bar.SetWidth(40)
				bar.ShowCounters = false
				//fmt.Printf("%s\n", step)
				//bar.NotPrint = true
				bar.Start()
				currentStep = step

			} else {
				process := &Process{Msg: stepToMsg(step) + "\t\t"}
				process.Start()
			}

		}
		if bar != nil {
			bar.Set64(progress)
		}

	})

	if bar != nil {
		bar.NotPrint = true
		bar.Finish()

		fmt.Printf(ascii2.EraseLines(2) + ascii2.EraseLine + fmt.Sprintf("  %s installed", l))
	}

	if process != nil {
		process.Done("\n")
	}
	//fmt.Printf(ascii2.EraseLine + ascii2.CursorUp(1) + ascii2.EraseLine)

	if err != nil {
		fmt.Printf("Could not install %s@%s: \n  %s\n", l, version, err.Error())
	} else {
		fmt.Printf("  %s@%s installed!\n\n", l, version)
	}

	return err
}
Exemple #2
0
				if bar != nil {
					bar.NotPrint = true
					bar.Finish()
					fmt.Printf(ascii2.EraseLine)

					bar = nil
				}

				if process != nil {
					process.Done("")
					process = nil
				}

				if total > 0 {
					bar = pb.New64(total).Prefix("  " + stepToMsg(step) + "\t\t")
					bar.SetWidth(40)
					bar.ShowCounters = false
					//fmt.Printf("%s\n", step)
					//bar.NotPrint = true
					bar.Start()
					currentStep = step

				} else {
					process := &Process{Msg: "  " + stepToMsg(step) + "\t\t"}
					process.Start()
				}

			}

			if bar != nil {
				bar.Set64(progress)