From: Goffredo Baroncelli <kreijack@libero.it>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: [PATCH 5/6] Show the help messages from the info in the comment.
Date: Tue, 19 Jul 2011 18:12:22 +0200 [thread overview]
Message-ID: <20110719161222.3210.30489.stgit@venice.bhome> (raw)
In-Reply-To: <20110719161049.3210.54794.stgit@venice.bhome>
From: Goffredo Baroncelli <kreijack@inwind.it>
The makefile is update in order to use the tool "helpextract" to extract
the info from the sources comments and to generate the file "helpmsg.c"
which contains an array of string with all the information.
Then the function "print_help" prints these information.
---
btrfs.c | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/btrfs.c b/btrfs.c
index 98abb6c..53422f7 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -357,6 +357,8 @@ static struct Command commands[] = {
{ 0, 0, 0, 0 }
};
+extern char * help_messages[];
+
static char *get_prgname(char *programname)
{
char *np;
@@ -372,21 +374,43 @@ static char *get_prgname(char *programname)
static void print_help(char *programname, struct Command *cmd, int helptype)
{
char *pc;
+ int i;
+ char *adv_help;
+ char *std_help;
+
+ /* printf("\t%s %s ", programname, cmd->verb ); */
+
+ adv_help = cmd->adv_help;
+ std_help = cmd->help;
+
+ for(i = 0; help_messages[i]; i+= 4 ){
+ if(!strncmp(help_messages[i],"btrfs ",6) &&
+ !strcmp(help_messages[i]+6,cmd->verb) ){
+ if(help_messages[i+2])
+ std_help = help_messages[i+2];
+ if(help_messages[i+3])
+ adv_help = help_messages[i+3];
+ printf("\t%s\t\t",help_messages[i+1]);
+ break;
+ }
+ }
- printf("\t%s %s ", programname, cmd->verb );
+ if( !help_messages[i])
+ printf("\t%s %s ", programname, cmd->verb );
- if (helptype == ADVANCED_HELP && cmd->adv_help)
- for(pc = cmd->adv_help; *pc; pc++){
+ if (helptype == ADVANCED_HELP && adv_help){
+ for(pc = adv_help; *pc; pc++){
putchar(*pc);
if(*pc == '\n')
printf("\t\t");
}
- else
- for(pc = cmd->help; *pc; pc++){
+ }else{
+ for(pc = std_help; *pc; pc++){
putchar(*pc);
if(*pc == '\n')
printf("\t\t");
}
+ }
putchar('\n');
}
next prev parent reply other threads:[~2011-07-19 16:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-19 16:11 [PATCH 0/6] Move the infor for the help/man page in the source Goffredo Baroncelli
2011-07-19 16:11 ` [PATCH 1/6] Add info for the commands Goffredo Baroncelli
2011-07-19 16:12 ` [PATCH 2/6] Add the header/footer/introduction of the man page Goffredo Baroncelli
2011-07-19 16:12 ` [PATCH 3/6] helpextract: tool to extract the info for the help from the source Goffredo Baroncelli
2011-07-19 16:12 ` [PATCH 4/6] Update the makefile for generating the man page Goffredo Baroncelli
2011-07-19 16:12 ` Goffredo Baroncelli [this message]
2011-07-19 16:12 ` [PATCH 6/6] Update the makefile for generating the help messages Goffredo Baroncelli
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=20110719161222.3210.30489.stgit@venice.bhome \
--to=kreijack@libero.it \
--cc=linux-btrfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).