[PATCH] Improve usage messages

2005-04-21 Thread Matthias Urlichs
This patch adds somewhat-improved usage messages to some of Linus' programs.
Specifically, they now handle -? / --help.

Signed-Off-By: Matthias Urlichs [EMAIL PROTECTED]

Index: check-files.c
===
--- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/check-files.c  (mode:100644 
sha1:7d16691aa9d51b5b4670d5837b3527ee7c7da79c)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/check-files.c  (mode:100644 
sha1:be904b13659a60eab31787b010a64f2274048a9f)
@@ -40,6 +40,8 @@
 {
int i;
 
+   if(argc == 2  (!strcmp(argv[1],-?) || !strcmp(argv[1],--help)))
+   usage(check-files filename...);
read_cache();
for (i = 1; i  argc ; i++)
check_file(argv[i]);
Index: diff-tree.c
===
--- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/diff-tree.c  (mode:100644 
sha1:b0122e42631410fa579115f025efc3cab777cde6)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/diff-tree.c  (mode:100644 
sha1:03fcc2fae2f0b06f3834f0b6e0d8762e70f49f51)
@@ -193,6 +193,11 @@
}
 }
 
+static const char diff_tree_usage[] = 
+   diff-tree [ -r (recurse) | -z (\\0-terminate) ]
+   \n\ttree sha1 tree sha1;
+
+
 int main(int argc, char **argv)
 {
unsigned char old[20], new[20];
@@ -209,11 +214,11 @@
line_termination = '\0';
continue;
}
-   usage(diff-tree [-r] [-z] tree sha1 tree sha1);
+   usage(diff_tree_usage);
}
 
if (argc != 3 || get_sha1_hex(argv[1], old) || get_sha1_hex(argv[2], 
new))
-   usage(diff-tree [-r] [-z] tree sha1 tree sha1);
+   usage(diff_tree_usage);
commit_to_tree(old);
commit_to_tree(new);
return diff_tree_sha1(old, new, );
--- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/init-db.c  (mode:100644 
sha1:dad06351ca35d0d2f68cd9e719c49805386f96fa)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/init-db.c  (mode:100644 
sha1:4afd436e719b347cdf6b4420c9d926e453f1f95b)
@@ -26,6 +26,9 @@
char *sha1_dir, *path;
int len, i;
 
+   if(argc != 1)
+   usage(init-db);
+
safe_create_dir(.git);
 
sha1_dir = getenv(DB_ENVIRONMENT);
--- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/write-tree.c  (mode:100644 
sha1:827809dbddbff6dd8cf842641f6db5ad2f3ae07a)
+++ 265515f9c4f089b1b61e9d2312c4b3babe189618/write-tree.c  (mode:100644 
sha1:55fe1c75c3065c8d5bef34f4f2e7af7aa147ea9d)
@@ -101,9 +101,13 @@
 int main(int argc, char **argv)
 {
int i, unmerged;
-   int entries = read_cache();
+   int entries;
unsigned char sha1[20];
 
+   if(argc != 1)
+   usage(write-tree);
+
+   entries = read_cache();
if (entries = 0)
die(write-tree: no cache contents to write);
 
-
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Improve usage messages

2005-04-21 Thread Petr Baudis
Dear diary, on Thu, Apr 21, 2005 at 02:41:52PM CEST, I got a letter
where Matthias Urlichs [EMAIL PROTECTED] told me that...
 This patch adds somewhat-improved usage messages to some of Linus' programs.
 Specifically, they now handle -? / --help.

-? is pretty non-standard. Any problem with going for -h?

 Signed-Off-By: Matthias Urlichs [EMAIL PROTECTED]
 
 Index: check-files.c
 ===
 --- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/check-files.c  (mode:100644 
 sha1:7d16691aa9d51b5b4670d5837b3527ee7c7da79c)
 +++ 265515f9c4f089b1b61e9d2312c4b3babe189618/check-files.c  (mode:100644 
 sha1:be904b13659a60eab31787b010a64f2274048a9f)
 @@ -40,6 +40,8 @@
  {
   int i;
  
 + if(argc == 2  (!strcmp(argv[1],-?) || !strcmp(argv[1],--help)))

(style-education-hat
+   if (argc == 2  (!strcmp(argv[1], -?) || !strcmp(argv[1], --help)))
)

 + usage(check-files filename...);

Let's either do filename* or FILE..., this mixing doesn't look good.

   read_cache();
   for (i = 1; i  argc ; i++)
   check_file(argv[i]);
 Index: diff-tree.c
 ===
 --- 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/diff-tree.c  (mode:100644 
 sha1:b0122e42631410fa579115f025efc3cab777cde6)
 +++ 265515f9c4f089b1b61e9d2312c4b3babe189618/diff-tree.c  (mode:100644 
 sha1:03fcc2fae2f0b06f3834f0b6e0d8762e70f49f51)
 @@ -193,6 +193,11 @@
   }
  }
  
 +static const char diff_tree_usage[] = 
 + diff-tree [ -r (recurse) | -z (\\0-terminate) ]
 + \n\ttree sha1 tree sha1;

I'd say this is pretty confusnig. Just describe the parameters on
folowing lines in more detail, if you must.

 +
 +
  int main(int argc, char **argv)
  {
   unsigned char old[20], new[20];

-- 
Petr Pasky Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
-
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Improve usage messages

2005-04-21 Thread David Greaves
Petr Baudis wrote:
Dear diary, on Thu, Apr 21, 2005 at 02:41:52PM CEST, I got a letter
where Matthias Urlichs [EMAIL PROTECTED] told me that...
This patch adds somewhat-improved usage messages to some of Linus' programs.
Specifically, they now handle -? / --help.
just so you know, the intention of doing the README.reference was to get 
all the docs in one place and then go back to the c and update the 
usage() to be consistent.

I started by doing
  grep usage *.c
:)
I'm actually working on diff-cache as we speak...
David
-
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html