[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: rev 1329 - trunk/subversion/svnadmin trunk/subversion/tests/clients/cmdline

From: Daniel Berlin <dan_at_dberlin.org>
Date: 2002-02-21 22:35:04 CET

On Thu, 21 Feb 2002, Blair Zajac wrote:

> Karl Fogel wrote:
> >
> > Blair Zajac <blair@orcaware.com> writes:
> > > I'm doing some refactoring of code from cl.h into svn_getopt.h. It
> > > would be handy if svn could do diffs that include file copies and
> > > renames, much like what arch does. Otherwise it's harder to send
> > > a patch in and keep the history.
> >
> > For now, you can just accompany the patch with human-readable
> > instructions about renames (agree that better support would be good,
> > and someday we'll have it). Your patch sounds interesting, want to
> > say more?
>
> As Greg mentioned, just to pull those program independent pieces that
> do getopt processing in cl.h and clients/cmdline/main.c out and create
> two new files, svn_getopt.h and svn_getopt.c. svnadmin/main.c's
> currently uses a large switch to decide what to do. However, cmdline/main.c
> supports a function call interface, so I'll break out the switch case
> statements into separate functions.

If you haven't accomplished pulling out the independent pieces, let me
know, I did it this morning in class.
This includes modifying them to take a table of commands (rather than
hardcoding some global name in), making valid_options non-fixed-size,
etc.

They are all named svn_cl_<whatever>, like svn_cl_print_command_info.

Here's a test program and the output (the header file is misnamed
getopt_new.h right now).

#include "getopt_new.h"
#include "svn_pools.h"
int main(void)
{
        int valid_opts[] = {'l',0};
        apr_getopt_option_t opttable[] = {
                { "long", 'l', 0, "Long option"},
                { "short", 's', 0, "Short option"}
        };
        svn_cl_cmd_t commands[] = {
                { "test", {"testalias1", 0}, "test help", valid_opts},
                0};
        apr_initialize();
        {
                apr_pool_t *pool = svn_pool_create(NULL);
                char *string;
                const svn_cl_cmd_t *cmd = commands;
                svn_cl_format_option(&string, &opttable[0], TRUE, pool);
                printf("%s\n", string);
                svn_cl_format_option(&string, &opttable[1], TRUE, pool);
                printf("%s\n", string);
                printf("%d\n", svn_cl_subcmd_has_option(&commands[0],
'l'));
                printf("%d\n", svn_cl_subcmd_has_option(&commands[0],
's'));
                svn_cl_print_command_info (&cmd, &commands[0], opttable,
TRUE, pool, stdout);
        }
        apr_terminate();
}

output:
-l [--long]: Long option
-s [--short]: Short option
1
0
test (testalias1): test help
Valid options:
  -l [--long]: Long option

If you've already taken care of splitting the stuff, disregard this
message.
--Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:09 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.