| "v.io/core/veyron/lib/modules" |
| modules.RegisterFunction(SleepCommand, `[duration] |
| sleep for a time(in go time.Duration format): defaults to 1s`, sleep) |
| modules.RegisterFunction(TimeCommand, ` |
| prints the current time`, now) |
| func sleep(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error { |
| if d, err = time.ParseDuration(args[1]); err != nil { |
| fmt.Fprintf(stdout, "Sleeping for %s\n", d) |
| eof := make(chan struct{}) |
| modules.WaitForEOF(stdin) |
| fmt.Fprintf(stdout, "Slept for %s\n", time.Now().Sub(then)) |
| fmt.Fprintf(stdout, "Aborted after %s\n", time.Now().Sub(then)) |
| func now(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error { |
| fmt.Fprintf(stdout, "%s\n", time.Now()) |