Beispiel #1
0
func GetInfo(c *cli.Context) {
	objectId := helper.ValidId(c.Args().First())

	_, err := data.GetObject(objectId)
	if err == nil {
		GetObject(c)
		return
	}

	_, err = data.GetAttachment(objectId)
	if err == nil {
		GetAttachmentInfo(c)
		return
	}

	helper.ErrExit(err != nil, fmt.Sprintf("Invalid object ID %s!\n", objectId))
}
Beispiel #2
0
func GetAttachmentInfo(c *cli.Context) {
	objectId := helper.ValidId(c.Args().First())

	attachment, err := data.GetAttachment(objectId)
	helper.ErrPanic(err)

	metadata := make(map[string]string)
	for _, attribute := range attachment.MetaData {
		metadata[attribute.Name] = attribute.Value
	}

	keys := make([]string, 0, len(metadata))
	for k := range metadata {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	fmt.Printf("%s\n\n", colors.Bold(attachment.Filename))
	fmt.Printf("%s\n\t%s\n", colors.Header("Uploaded"), attachment.UploadDate.Format(time.RFC1123))

	for _, name := range keys {
		fmt.Printf("%s\n\t%v\n", colors.Header(name), metadata[name])
	}
}