Esempio n. 1
0
File: main.go Progetto: bryanwb/kh
func (p *Finger) Execute(fa *kh.FingerArgs, resp *kh.Response) error {
	// wish there was a more elegant way to set the logging level
	resp.SetVerbose(fa.Flags.Verbose)
	args := fa.Args
	if len(args) < 1 && fa.Stdin == nil {
		return errors.New("Hey buddy, I need a name")
	}
	if fa.Stdin != nil {
		resp.WriteStdout("Hello, " + strings.TrimSpace(string(fa.Stdin)))
	} else {
		resp.WriteStdout("Hello, " + args[0])
	}
	return nil
}
Esempio n. 2
0
func (p *Finger) Execute(fa *kh.FingerArgs, resp *kh.Response) error {
	resp.Debug("Inside execute")
	// wish there was a more elegant way to set the logging level
	resp.SetVerbose(fa.Flags.Verbose)
	if fa.Flags.Help {
		resp.Debugf("About to execute %s", "help")
		resp.WriteStdout(p.Help())
		return nil
	}
	args := fa.Args
	if len(args) < 1 {
		return errors.New("Hey buddy, I need a name")
	} else {
		resp.WriteStdout("Hello, " + args[0])
	}
	return nil
}
Esempio n. 3
0
File: main.go Progetto: bryanwb/kh
func (p *Finger) Help(fa *kh.FingerArgs, resp *kh.Response) error {
	resp.SetVerbose(fa.Flags.Verbose)
	resp.WriteStdout("Hi, I am easy to use")
	return nil
}