From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 3/7] parseopt: OPT_COLUMN to set struct column_layout.mode
Date: Tue, 8 Feb 2011 22:22:17 +0700 [thread overview]
Message-ID: <1297178541-31124-4-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1297178541-31124-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
column.c | 18 ++++++++++++++++++
column.h | 3 +++
parse-options.h | 2 ++
3 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/column.c b/column.c
index 4b92fa5..c4a90d5 100644
--- a/column.c
+++ b/column.c
@@ -175,3 +175,21 @@ void display_columns(const struct column_layout *c, int padding, const char *ind
die("BUG: invalid mode %d", c->mode & COL_MODE);
}
}
+
+int parseopt_column_callback(const struct option *opt, const char *arg, int unset)
+{
+ struct column_layout *cp = opt->value;
+ if (unset) {
+ cp->mode = COL_PLAIN;
+ return 0;
+ }
+ if (!arg || !strcmp(arg, "column")) {
+ cp->mode |= COL_COLUMN_FIRST;
+ return 0;
+ }
+ if (!strcmp(arg, "dense")) {
+ cp->mode |= COL_DENSE;
+ return 0;
+ }
+ return error("unsupported style '%s'", arg);
+}
diff --git a/column.h b/column.h
index 34435b0..7f0ae74 100644
--- a/column.h
+++ b/column.h
@@ -17,4 +17,7 @@ struct column_layout {
extern void display_columns(const struct column_layout *c, int padding, const char *indent);
+struct option;
+extern int parseopt_column_callback(const struct option *opt, const char *arg, int unset);
+
#endif
diff --git a/parse-options.h b/parse-options.h
index 31ec5d2..2fed453 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -145,6 +145,8 @@ struct option {
#define OPT_COLOR_FLAG(s, l, v, h) \
{ OPTION_CALLBACK, (s), (l), (v), "when", (h), PARSE_OPT_OPTARG, \
parse_opt_color_flag_cb, (intptr_t)"always" }
+#define OPT_COLUMN(s, l, v, h) \
+ { OPTION_CALLBACK, (s), (l), (v), "style", (h), PARSE_OPT_OPTARG, parseopt_column_callback }
/* parse_options() will filter out the processed options and leave the
--
1.7.2.2
next prev parent reply other threads:[~2011-02-08 15:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-08 15:22 [PATCH/RFC 0/7] Column output Nguyễn Thái Ngọc Duy
2011-02-08 15:22 ` [PATCH 1/7] Move term_columns() to pager.c and save terminal width before pager Nguyễn Thái Ngọc Duy
2011-02-09 5:14 ` Jonathan Nieder
2011-02-08 15:22 ` [PATCH 2/7] Add column layout Nguyễn Thái Ngọc Duy
2011-02-09 7:36 ` Jonathan Nieder
2011-02-09 11:24 ` Nguyen Thai Ngoc Duy
2011-02-08 15:22 ` Nguyễn Thái Ngọc Duy [this message]
2011-02-08 15:22 ` [PATCH 4/7] add core.column Nguyễn Thái Ngọc Duy
2011-02-08 15:22 ` [PATCH 5/7] help: reuse struct column_layout Nguyễn Thái Ngọc Duy
2011-02-09 7:39 ` Jonathan Nieder
2011-02-09 11:21 ` Nguyen Thai Ngoc Duy
2011-02-08 15:22 ` [PATCH 6/7] tag: support column output with --column Nguyễn Thái Ngọc Duy
2011-02-09 21:51 ` Junio C Hamano
2011-02-10 2:35 ` Nguyen Thai Ngoc Duy
2011-02-10 2:54 ` Miles Bader
2011-02-08 15:22 ` [PATCH 7/7] branch: " Nguyễn Thái Ngọc Duy
2011-02-08 22:47 ` [PATCH/RFC 0/7] Column output Jeff King
2011-02-09 0:13 ` Nguyen Thai Ngoc Duy
2011-02-09 5:42 ` Jonathan Nieder
2011-02-09 5:59 ` Nguyen Thai Ngoc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1297178541-31124-4-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.