Пример #1
0
func (t *TermBackend) CatFile(data interface{}, client server.ProtocolClient) error {
	d, _ := data.([][]byte)
	if len(d) > 0 {
		fileName := string(d[0])
		content, err := ioutil.ReadFile(path.Join(t.homeDir, fileName))
		if err != nil {
			client.WriteError(err)
		} else {
			client.WriteBytes(content)
		}
		client.Flush()
	} else {
		client.WriteError(errors.New("cat takes at least 1 parameter (cat filename)"))
		client.Flush()
	}

	return nil
}
Пример #2
0
func (t *TermBackend) ShowResume(data interface{}, client server.ProtocolClient) error {
	client.WriteBytes(t.resumeText)
	client.Flush()
	return nil
}