Beispiel #1
0
// String string printer for copy message
func (c CopyMessage) String() string {
	if !globalJSONFlag {
		return fmt.Sprintf("‘%s’ -> ‘%s’\n", c.Source, c.Target)
	}
	c.Version = "1.0.0"
	copyMessageBytes, err := json.MarshalIndent(c, "", "\t")
	if err != nil {
		panic(err)
	}
	return console.JSON(string(copyMessageBytes) + "\n")
}
Beispiel #2
0
// String string printer for cast message
func (s CastMessage) String() string {
	if !globalJSONFlag {
		return fmt.Sprintf("‘%s’ -> ‘%s’\n", s.Source, s.Targets)
	}
	s.Version = "1.0.0"
	castMessageBytes, err := json.MarshalIndent(s, "", "\t")
	if err != nil {
		panic(err)
	}
	return console.JSON(string(castMessageBytes) + "\n")
}
Beispiel #3
0
// String string printer for Content metadata
func (c Content) String() string {
	if !globalJSONFlag {
		message := console.Time("[%s] ", c.Time)
		message = message + console.Size("%6s ", c.Size)
		message = func() string {
			if c.Filetype == "folder" {
				return message + console.Dir("%s", c.Name)
			}
			return message + console.File("%s", c.Name)
		}()
		return message + "\n"
	}
	c.Version = "1.0.0"
	jsonMessageBytes, err := json.MarshalIndent(c, "", "\t")
	if err != nil {
		panic(err)
	}
	return console.JSON(string(jsonMessageBytes) + "\n")
}
Beispiel #4
0
func (s sessionV2) String() string {
	if !globalJSONFlag {
		message := console.SessionID("%s -> ", s.SessionID)
		message = message + console.Time("[%s]", s.Header.When.Local().Format(printDate))
		message = message + console.Command(" %s %s", s.Header.CommandType, strings.Join(s.Header.CommandArgs, " "))
		return message + "\n"
	}
	sessionMesage := SessionJSONMessage{
		Version:     s.Header.Version,
		SessionID:   s.SessionID,
		Time:        s.Header.When.Local().Format(printDate),
		CommandType: s.Header.CommandType,
		CommandArgs: s.Header.CommandArgs,
	}
	sessionJSONBytes, err := json.MarshalIndent(sessionMesage, "", "\t")
	if err != nil {
		panic(err)
	}
	return console.JSON(string(sessionJSONBytes) + "\n")
}