On Wed, 7 Mar 2001, B. W. Fitzpatrick wrote:
> Well, we could always just have it print out the command specific help...
...
> Is this really worth it? Looking through the commands that we need to
> support, it seems like only a few have this requirement:
...
> I would vote to leave the checking in the command, although I don't
> feel all that strongly about it. Does anyone else have any feelings on
> this?
I went ahead and implemented the number of args checking
inside the command. You were right, it is a lot more simple
this way. I am not suggesting that the following patch
should be checked in, I am just posting it as an example of
what I was trying to do. There are still a couple of problems.
For one thing, I am just calling exit right now. It is
a cheap hack that needs to be fixed. I am also a little
stumped about how one would use the apr_table_clear()
method with a apr_array_header_t type (see checkout-cmd.c).
I am sure I must be missing something that is dead simple,
but I am new to this code.
Mo DeJong
Red Hat Inc
Index: add-cmd.c
===================================================================
RCS file: /cvs/subversion/subversion/client/add-cmd.c,v
retrieving revision 1.11
diff -u -r1.11 add-cmd.c
--- add-cmd.c 2000/11/22 23:48:37 1.11
+++ add-cmd.c 2001/03/08 08:33:23
@@ -48,10 +48,10 @@
}
else
{
- fprintf (stderr, "svn add: arguments required\n");
- err = svn_cl__help (opt_state, targets, pool);
- if (err)
- return err;
+ svn_cl__push_svn_string (targets, pool, "add");
+ svn_cl__help (NULL, targets, pool);
+ apr_pool_destroy (pool);
+ exit (EXIT_FAILURE);
}
return SVN_NO_ERROR;
Index: checkout-cmd.c
===================================================================
RCS file: /cvs/subversion/subversion/client/checkout-cmd.c,v
retrieving revision 1.11
diff -u -r1.11 checkout-cmd.c
--- checkout-cmd.c 2001/02/06 00:45:51 1.11
+++ checkout-cmd.c 2001/03/08 08:33:23
@@ -38,6 +38,18 @@
void *trace_edit_baton;
svn_error_t *err;
+ if (targets->nelts)
+ {
+ /* FIXME: How the heck do you clear an apr_array_header_t ??
+ apr_table_clear() takes a apr_table_t so it don't work */
+ targets->nelts = 0;
+
+ svn_cl__push_svn_string (targets, pool, "checkout");
+ svn_cl__help (NULL, targets, pool);
+ apr_pool_destroy (pool);
+ exit (EXIT_FAILURE);
+ }
+
err = svn_cl__get_trace_update_editor (&trace_editor,
&trace_edit_baton,
opt_state->target,
Index: cl.h
===================================================================
RCS file: /cvs/subversion/subversion/client/cl.h,v
retrieving revision 1.36
diff -u -r1.36 cl.h
--- cl.h 2001/03/07 07:33:39 1.36
+++ cl.h 2001/03/08 08:33:23
@@ -107,6 +107,11 @@
svn_cl__diff,
svn_cl__update;
+
+void svn_cl__push_svn_string(apr_array_header_t *array,
+ apr_pool_t *pool,
+ const char *str);
+
void push_implicit_dot_target(apr_array_header_t *targets, apr_pool_t
*pool);
Index: delete-cmd.c
===================================================================
RCS file: /cvs/subversion/subversion/client/delete-cmd.c,v
retrieving revision 1.12
diff -u -r1.12 delete-cmd.c
--- delete-cmd.c 2000/11/22 23:48:37 1.12
+++ delete-cmd.c 2001/03/08 08:33:24
@@ -48,10 +48,10 @@
}
else
{
- fprintf (stderr, "svn delete: arguments required\n");
- err = svn_cl__help (opt_state, targets, pool);
- if (err)
- return err;
+ svn_cl__push_svn_string (targets, pool, "delete");
+ svn_cl__help (NULL, targets, pool);
+ apr_pool_destroy (pool);
+ exit (EXIT_FAILURE);
}
return SVN_NO_ERROR;
Index: main.c
===================================================================
RCS file: /cvs/subversion/subversion/client/main.c,v
retrieving revision 1.64
diff -u -r1.64 main.c
--- main.c 2001/03/07 07:33:39 1.64
+++ main.c 2001/03/08 08:33:24
@@ -122,16 +123,22 @@
};
+void svn_cl__push_svn_string (apr_array_header_t *array,
+ apr_pool_t *pool,
+ const char *str)
+{
+ (*((svn_string_t **) apr_array_push (array)))
+ = svn_string_create (str, pool);
+}
+
/* Some commands take an implicit "." string argument when invoked
* with no arguments. Those commands make use of this function to
* add "." to the target array if the user passes no args */
-void push_implicit_dot_target(apr_array_header_t *targets, apr_pool_t *pool)
+void push_implicit_dot_target (apr_array_header_t *targets, apr_pool_t
*pool)
{
- if (targets->nelts == 0) {
- (*((svn_string_t **) apr_array_push (targets)))
- = svn_string_create (".", pool);
- }
- assert(targets->nelts);
+ if (targets->nelts == 0)
+ svn_cl__push_svn_string (targets, pool, ".");
+ assert (targets->nelts);
}
/* Return the entry in svn_cl__cmd_table whose name matches CMD_NAME,
@@ -389,9 +396,7 @@
return EXIT_FAILURE;
}
this_arg = os->argv[os->ind++];
- (*((svn_string_t **) apr_array_push (opt_state.args)))
- = svn_string_create (this_arg, pool);
-
+ svn_cl__push_svn_string (opt_state.args, pool, this_arg);
}
}
/* greedily suck up all args if num_args is a negative number. */
@@ -407,8 +412,7 @@
for (; os->ind < os->argc; os->ind++)
{
const char *this_arg = os->argv[os->ind];
- (*((svn_string_t **) apr_array_push (targets)))
- = svn_string_create (this_arg, pool);
+ svn_cl__push_svn_string (targets, pool, this_arg);
}
/* kff todo: need to remove redundancies from targets before
Received on Sat Oct 21 14:36:25 2006