diff cmd.c @ 15:3380c8fd9776

Show all record fields except the password by default
author Guido Berhoerster <guido+pwm@berhoerster.name>
date Mon, 07 Aug 2017 19:11:56 +0200
parents a01899a6e4bb
children a07665727c19
line wrap: on
line diff
--- a/cmd.c	Mon Aug 07 18:16:47 2017 +0200
+++ b/cmd.c	Mon Aug 07 19:11:56 2017 +0200
@@ -720,7 +720,16 @@
 	struct record	*record;
 	int		i;
 	enum field_type	type;
-	int		fields[COUNTOF(field_namev) - 1] = { 0 };
+	int		fields[COUNTOF(field_namev) - 1] = {
+		[FIELD_GROUP] = 1,
+		[FIELD_TITLE] = 1,
+		[FIELD_USERNAME] = 1,
+		[FIELD_PASSWORD] = 0,
+		[FIELD_NOTES] = 1,
+		[FIELD_URL] = 1,
+		[FIELD_MTIME] = 1,
+		[FIELD_CTIME] = 1
+	};
 
 	if (argc < 2) {
 		return (CMD_USAGE);
@@ -731,6 +740,11 @@
 		return (CMD_ERR);
 	}
 
+	if (argc > 2) {
+		/* show only explicitly given field names */
+		memset(fields, 0, sizeof (fields));
+	}
+
 	for (i = 2; i < argc; i++) {
 		type = parse_arg(argv[i], field_namev, '\0', NULL);
 		if (type < 0) {