git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Improve usage messages
@ 2005-04-21 12:41 Matthias Urlichs
  2005-04-21 16:25 ` Petr Baudis
  2005-04-21 23:02 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Matthias Urlichs @ 2005-04-21 12:41 UTC (permalink / raw)
  To: git

This patch adds somewhat-improved usage messages to some of Linus' programs.
Specifically, they now handle -? / --help.

Signed-Off-By: Matthias Urlichs <smurf@smurf.noris.de>

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\t<tree 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");
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Improve usage messages
  2005-04-21 12:41 [PATCH] Improve usage messages Matthias Urlichs
@ 2005-04-21 16:25 ` Petr Baudis
  2005-04-21 16:43   ` David Greaves
  2005-04-21 23:02 ` Junio C Hamano
  1 sibling, 1 reply; 4+ messages in thread
From: Petr Baudis @ 2005-04-21 16:25 UTC (permalink / raw)
  To: Matthias Urlichs; +Cc: git

Dear diary, on Thu, Apr 21, 2005 at 02:41:52PM CEST, I got a letter
where Matthias Urlichs <smurf@smurf.noris.de> 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 <smurf@smurf.noris.de>
> 
> 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\t<tree 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Improve usage messages
  2005-04-21 16:25 ` Petr Baudis
@ 2005-04-21 16:43   ` David Greaves
  0 siblings, 0 replies; 4+ messages in thread
From: David Greaves @ 2005-04-21 16:43 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Matthias Urlichs, git

Petr Baudis wrote:
> Dear diary, on Thu, Apr 21, 2005 at 02:41:52PM CEST, I got a letter
> where Matthias Urlichs <smurf@smurf.noris.de> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Improve usage messages
  2005-04-21 12:41 [PATCH] Improve usage messages Matthias Urlichs
  2005-04-21 16:25 ` Petr Baudis
@ 2005-04-21 23:02 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2005-04-21 23:02 UTC (permalink / raw)
  To: Matthias Urlichs; +Cc: git

>>>>> "MU" == Matthias Urlichs <smurf@smurf.noris.de> writes:

MU> Index: diff-tree.c

MU> +static const char diff_tree_usage[] = 
MU> +	"diff-tree [ -r (recurse) | -z (\\0-terminate) ]"
MU> +		"\n\t<tree sha1> <tree sha1>";

I think we already have this, and Pasky's right to say the
(recurse) and (\0-terminate) should not be there.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-04-21 22:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-21 12:41 [PATCH] Improve usage messages Matthias Urlichs
2005-04-21 16:25 ` Petr Baudis
2005-04-21 16:43   ` David Greaves
2005-04-21 23:02 ` Junio C Hamano

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).