本文整理汇总了Golang中github.com/catalyzeio/cli/lib/prompts.IPrompts.PHI方法的典型用法代码示例。如果您正苦于以下问题:Golang IPrompts.PHI方法的具体用法?Golang IPrompts.PHI怎么用?Golang IPrompts.PHI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/catalyzeio/cli/lib/prompts.IPrompts
的用法示例。
在下文中一共展示了IPrompts.PHI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CmdDownload
func CmdDownload(databaseName, backupID, filePath string, force bool, id IDb, ip prompts.IPrompts, is services.IServices) error {
err := ip.PHI()
if err != nil {
return err
}
if !force {
if _, err := os.Stat(filePath); err == nil {
return fmt.Errorf("File already exists at path '%s'. Specify `--force` to overwrite", filePath)
}
} else {
os.Remove(filePath)
}
service, err := is.RetrieveByLabel(databaseName)
if err != nil {
return err
}
if service == nil {
return fmt.Errorf("Could not find a service with the label \"%s\". You can list services with the \"catalyze services\" command.", databaseName)
}
err = id.Download(backupID, filePath, service)
if err != nil {
return err
}
logrus.Printf("%s backup downloaded successfully to %s", databaseName, filePath)
logrus.Printf("You can also view logs for this backup with the \"catalyze db logs %s %s\" command", databaseName, backupID)
return nil
}
示例2: CmdExport
func CmdExport(databaseName, filePath string, force bool, id IDb, ip prompts.IPrompts, is services.IServices, ij jobs.IJobs) error {
err := ip.PHI()
if err != nil {
return err
}
if !force {
if _, err := os.Stat(filePath); err == nil {
return fmt.Errorf("File already exists at path '%s'. Specify `--force` to overwrite", filePath)
}
} else {
os.Remove(filePath)
}
service, err := is.RetrieveByLabel(databaseName)
if err != nil {
return err
}
if service == nil {
return fmt.Errorf("Could not find a service with the label \"%s\". You can list services with the \"catalyze services\" command.", databaseName)
}
job, err := id.Backup(service)
if err != nil {
return err
}
logrus.Printf("Export started (job ID = %s)", job.ID)
// all because logrus treats print, println, and printf the same
logrus.StandardLogger().Out.Write([]byte("Polling until export finishes."))
status, err := ij.PollTillFinished(job.ID, service.ID)
if err != nil {
return err
}
job.Status = status
logrus.Printf("\nEnded in status '%s'", job.Status)
if job.Status != "finished" {
id.DumpLogs("backup", job, service)
return fmt.Errorf("Job finished with invalid status %s", job.Status)
}
err = id.Export(filePath, job, service)
if err != nil {
return err
}
err = id.DumpLogs("backup", job, service)
if err != nil {
return err
}
logrus.Printf("%s exported successfully to %s", service.Name, filePath)
return nil
}