本文整理匯總了Golang中github.com/ernestokarim/cb/registry.Queue.NextTask方法的典型用法代碼示例。如果您正苦於以下問題:Golang Queue.NextTask方法的具體用法?Golang Queue.NextTask怎麽用?Golang Queue.NextTask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ernestokarim/cb/registry.Queue
的用法示例。
在下文中一共展示了Queue.NextTask方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: service
func service(c *config.Config, q *registry.Queue) error {
name := q.NextTask()
if name == "" {
return fmt.Errorf("first arg should be the name of the service")
}
q.RemoveNextTask()
module := q.NextTask()
if module == "" {
return fmt.Errorf("second arg should be the module of the service")
}
q.RemoveNextTask()
data := &serviceData{
Name: name,
Module: module,
Filename: filepath.Join(strings.Split(module, ".")...),
}
if err := writeServiceFile(data); err != nil {
return fmt.Errorf("write service failed: %s", err)
}
if err := writeServiceTestFile(data); err != nil {
return fmt.Errorf("write service test failed: %s", err)
}
return nil
}
示例2: doForm
func doForm(c *config.Config, q *registry.Queue, mode string) error {
if !templates.IsRegistered(mode) {
return fmt.Errorf("unrecognized template mode: %s", mode)
}
templates.SetMode(mode)
filename := q.NextTask()
if filename == "" {
return fmt.Errorf("validator filename not passed as an argument")
}
q.RemoveNextTask()
form, err := parseForm(filename)
if err != nil {
return fmt.Errorf("parse form failed: %s", err)
}
result := strings.Replace(form.Build(), "'", `'"'"'`, -1)
args := []string{
"-c", fmt.Sprintf(`echo -n '%s' | xsel -bi`, result),
}
output, err := utils.Exec("bash", args)
if err != nil {
fmt.Println(output)
return fmt.Errorf("bash error: %s", err)
}
return nil
}
示例3: push
func push(c *config.Config, q *registry.Queue) error {
scriptsPath := utils.PackagePath(selfPkg)
host := c.GetRequired("push")
// FTP User & password
user := q.NextTask()
if user == "" {
return fmt.Errorf("ftp user required as the first argument")
}
q.RemoveNextTask()
password, err := gopass.GetPass(fmt.Sprintf("Enter \"%s\" password: ", user))
if err != nil {
return fmt.Errorf("cannot read password: %s", err)
}
if password == "" {
return fmt.Errorf("ftp password is required")
}
// Hash local files
log.Printf("Hashing local files... ")
localHashes, err := hashLocalFiles()
if err != nil {
return fmt.Errorf("hash local files failed: %s", err)
}
log.Printf("Hashing local files... %s[SUCCESS]%s\n", colors.Green, colors.Reset)
// Hash remote files
log.Printf("Hashing remote files... ")
remoteHashes, err := retrieveRemoteHashes(scriptsPath, user, password, host)
if err != nil {
return fmt.Errorf("retrieve remote hashes failed: %s", err)
}
log.Printf("Hashing remote files... %s[SUCCESS]%s\n", colors.Green, colors.Reset)
if err := saveLocalHashes(localHashes); err != nil {
return fmt.Errorf("save local hashes failed: %s", err)
}
// Prepare FTP commands
log.Printf("Preparing FTP commands... ")
if err := prepareFTPCommands(localHashes, remoteHashes); err != nil {
return fmt.Errorf("prepare FTP commands failed: %s", err)
}
log.Printf("Preparing FTP commands... %s[SUCCESS]%s\n", colors.Green, colors.Reset)
// Upload files
log.Printf("Uploading files... ")
if err := uploadFiles(scriptsPath, user, password, host); err != nil {
return fmt.Errorf("uploading files failed: %s", err)
}
log.Printf("Uploading files... %s[SUCCESS]%s\n", colors.Green, colors.Reset)
return nil
}
示例4: controller
func controller(c *config.Config, q *registry.Queue) error {
name := q.NextTask()
if name == "" {
return fmt.Errorf("first arg should be the name of the controller")
}
q.RemoveNextTask()
if !strings.Contains(name, "Ctrl") {
name = name + "Ctrl"
}
module := q.NextTask()
if module == "" {
return fmt.Errorf("second arg should be the module of the controller")
}
q.RemoveNextTask()
route := q.NextTask()
q.RemoveNextTask()
data := &controllerData{
Name: name,
Module: module,
Route: route,
Filename: filepath.Join(strings.Split(module, ".")...),
AppPath: c.GetDefault("paths.app", filepath.Join("app", "scripts", "app.js")),
}
if err := writeControllerFile(data); err != nil {
return fmt.Errorf("write controller failed: %s", err)
}
if err := writeControllerTestFile(data); err != nil {
return fmt.Errorf("write controller test failed: %s", err)
}
if err := writeControllerViewFile(data); err != nil {
return fmt.Errorf("write view failed: %s", err)
}
if route != "" {
if err := writeControllerRouteFile(data); err != nil {
return fmt.Errorf("write route failed: %s", err)
}
}
return nil
}