本文整理匯總了Golang中github.com/jwaldrip/odin/cli.Command.Param方法的典型用法代碼示例。如果您正苦於以下問題:Golang Command.Param方法的具體用法?Golang Command.Param怎麽用?Golang Command.Param使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/jwaldrip/odin/cli.Command
的用法示例。
在下文中一共展示了Command.Param方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (v *Run) Run(c cli.Command) {
jobName := c.Param("jobname").String()
log.WithFields(
log.Fields{
"pkg": "command",
"func": "Run",
"job": jobName,
},
).Info("Starting job")
j := job.New(metl.GetJobFilePath(jobName))
j.Lock()
jf, err := j.Fetch()
if err != nil {
log.Fatal("Error fetching job:", err)
}
jf.Run()
j.Unlock()
j.Done(jf)
// log stats, notify of errors etc
// notify of any errors
// log stats to dashboard, number of processed, rejected rows etc.
// if parsing option is empty then, we just download the file
}
示例2: greetGreetee
func greetGreetee(c cli.Command) {
greeting := c.Parent().Param("greeting")
greetee := c.Param("greetee")
str := fmt.Sprintf("%s %s", greeting, greetee)
str = styleByFlags(str, c)
c.Println(str, strings.Join(c.Args().Strings(), " "))
}
示例3: nodeRun
func nodeRun(c cli.Command) {
switch c.Param("action").String() {
case "list":
nodeList(c)
default:
cli.ShowUsage(c)
}
}
示例4: Run
func (v *Add) Run(c cli.Command) {
jobName := c.Param("jobname").String()
var job job.Job
if _, err := toml.DecodeFile(metl.GetJobFilePath(jobName)+".toml", &job); err != nil {
log.Fatal(err)
}
cronfile := filepath.Join(metl.Etl.GetLocalStoragePath(), crontabFile)
file, err := os.Open(cronfile)
if err != nil {
file, err = os.Create(cronfile)
if err != nil {
log.WithFields(
log.Fields{
"filename": cronfile,
},
).Fatal("Unable to create cronfile: ", err)
}
}
defer file.Close()
err = syscall.Flock(int(file.Fd()), syscall.LOCK_EX)
if err != nil {
log.Fatal("Failed to lock file")
}
defer func() {
err = syscall.Flock(int(file.Fd()), syscall.LOCK_UN)
if err != nil {
log.Fatal("Failed to unlock file")
}
}()
buffer := make([]string, 0)
if err = jobIsInFile(file, jobName, &buffer); err != nil {
log.Fatal(err)
}
buffer = append(buffer, fmt.Sprintf("%s %s >> %s%s.log", cmd, jobName, logDir, jobName))
tmpf, err := ioutil.TempFile(metl.Etl.GetLocalStoragePath(), "tmp")
if err != nil {
log.Fatal("Unable to create temporary file.")
}
for _, line := range buffer {
if _, err := tmpf.WriteString(line + "\n"); err != nil {
log.Fatal("Unable to write to temporary file")
}
}
if err := os.Rename(tmpf.Name(), cronfile); err != nil {
log.Fatal("Failed to rename temporary lock file:", err)
}
// execute /usr/bin/env crontab cronfile
}
示例5: roleRun
func roleRun(c cli.Command) {
switch c.Param("action").String() {
case "list":
roleList(c)
case "set":
roleSet(c)
default:
cli.ShowUsage(c)
}
}
示例6: serviceRun
func serviceRun(c cli.Command) {
switch c.Param("action").String() {
case "list":
serviceList(c)
case "local":
serviceLocal(c)
case "find":
serviceFind(c)
default:
cli.ShowUsage(c)
}
}
示例7: cmRun
func cmRun(c cli.Command) {
switch c.Param("action").String() {
case "local":
cmLocal(c)
case "roll":
cmRoll(c)
case "single":
cmSingle(c)
default:
cli.ShowUsage(c)
}
}
示例8: roleRun
func roleRun(c cli.Command) {
switch c.Param("action").String() {
case "list":
roleList(c)
case "set":
roleSet(c)
case "listAll":
roleListAll(c)
case "find":
roleFind(c)
case "append":
roleAppend(c)
case "rm":
roleRm(c)
default:
cli.ShowUsage(c)
}
}
示例9: greet
// the greet command run by the root command
func greet(c cli.Command) {
greeting := c.Param("greeting")
str := fmt.Sprintf("%s", greeting)
str = styleByFlags(str, c)
c.Println(str)
}