func showItemJson(item onepass.Item) { fmt.Printf("%s: %s: %s\n", item.Title, item.Uuid, item.ContentsHash) decrypted, err := item.ContentJson() if err != nil { fmt.Fprintf(os.Stderr, "Failed to decrypt item: %s: %v", item.Title, err) return } fmt.Println(string(prettyJson([]byte(decrypted)))) }
func showItem(vault *onepass.Vault, item onepass.Item) { typeName := item.TypeName itemType, ok := onepass.ItemTypes[item.TypeName] if ok { typeName = itemType.Name } fmt.Printf("%s (%s)\n", item.Title, typeName) fmt.Printf("Info:\n") fmt.Printf(" ID: %s\n", item.Uuid) updateTime := int64(item.UpdatedAt) if updateTime == 0 { updateTime = int64(item.CreatedAt) } fmt.Printf(" Updated: %s\n", time.Unix(updateTime, 0).Format("15:04 02/01/06")) if len(item.FolderUuid) > 0 { folder, err := vault.LoadItem(item.FolderUuid) if err != nil { fmt.Fprintf(os.Stderr, "Item folder '%s' not found", item.FolderUuid) // continue } fmt.Printf(" Folder: %s\n", folder.Title) } if len(item.OpenContents.Tags) > 0 { fmt.Printf(" Tags: %s\n", strings.Join(item.OpenContents.Tags, ", ")) } fmt.Println() content, err := item.Content() if err != nil { fmt.Fprintf(os.Stderr, "Failed to decrypt item: %s: %v", item.Title, err) return } fmt.Printf(content.String()) }