Welcome to Web-News
A Web-based News Reader
Subject Re: Command-line arguments
From superdan <super@dan.org>
Date Sat, 05 Jul 2008 14:50:47 -0400
Newsgroups digitalmars.D

Lars Ivar Igesund Wrote:

> superdan wrote:
>
> > Lars Ivar Igesund Wrote:
> >
> >> superdan wrote:
> >>
> >> > Lars Ivar Igesund Wrote:
> >> >
> >> >> As for preserving and enforcing order, that was one of the design
> >> >> goals for this implementation and thus it should be considered a bug
> >> >> if not easily done.
> >> >
> >> > put in layman's terms: making it unusable for applications that launch
> >> > secondary commands was a design goal.
> >>
> >> No.
> >
> > then parse this using tango arguments please:
> >
> > ssh -v ls -la
> >
> > thanks.
>
> Everything until ls is easy (including the hostname which is required by
> ssh), but it appears to ignore the -la part which I have noted to the
> implementors. I believe I did say that although the requirments document (I
> probably wrongly said design document) mandates that this should be
> possible, the implementation and design is not fully reviewed yet and may
> have bugs.
>
> The order is completely preserved and enforcable though.

rats! i forgot the hostname indeed. ok let me fix:

ssh -v host ls -la

my question is, assuming all bugs are fixed, how does the code for parsing this look like with tango arguments?

to make things more interesting, let's use this example:

ssh -v host -v ls -la

everything before and after host but before command is an option for ssh. everything after command is passed to the command.

could you show how this is coded (assuming bugs are fixed) in both tango arguments apis. thanks.

here's my std.getopt implementation for the example. let's see how others fare.

void main(string[] args)
{
    auto offset = find!("a.length && a[0] == '-'")(args) - begin(args);
    enforce(offset != args.length, "Hostname not specified");
    auto host = args[offset];
    args = args[0 .. offset] ~ args[offset + 1 .. $];
    uint verbosityLevel;
    ............
    getopt(args,
        std.getopt.config.stopOnFirstNonOption,
        "v+", &verbosityLevel,
        ......... more stuff ......);
    if (args.length)
    {
        ........... start shell session on host .........
    }
    else
    {
        ........... run command on host ..........
    }
}


Recent messages in this thread
 
-# Command-line arguments Matt 03-Jul-2008 08:30 pm
.-# Re: Command-line arguments Jarrett Billingsley 03-Jul-2008 09:25 pm
.|-# Re: Command-line arguments Bill Baxter 03-Jul-2008 09:32 pm
.||-# Re: Command-line arguments superdan 04-Jul-2008 12:45 am
.||.|# Re: Command-line arguments superdan 04-Jul-2008 12:50 am
.||.-# Re: Command-line arguments Steven Schveighoffer 04-Jul-2008 09:19 am
.||..-# Re: Command-line arguments superdan 04-Jul-2008 10:53 am
.||...-# Re: Command-line arguments Steven Schveighoffer 04-Jul-2008 11:43 am
.||...|-# Re: Command-line arguments superdan 04-Jul-2008 01:25 pm
.||...|.-# Re: Command-line arguments Sean Kelly 04-Jul-2008 02:44 pm
.||...|.||# Re: Command-line arguments Lars Ivar Igesund 04-Jul-2008 03:16 pm
.||...|.|\# Re: Command-line arguments superdan 04-Jul-2008 03:21 pm
.||...|.\# Re: Command-line arguments Steven Schveighoffer 06-Jul-2008 10:21 am
.||...-# Re: Command-line arguments Lars Ivar Igesund 04-Jul-2008 04:19 pm
.||....-# Re: Command-line arguments superdan 04-Jul-2008 05:58 pm
.||.....-# Re: Command-line arguments Lars Ivar Igesund 04-Jul-2008 06:23 pm
.||......-# Re: Command-line arguments superdan 04-Jul-2008 10:29 pm
.||.......-# Re: Command-line arguments Lars Ivar Igesund 05-Jul-2008 08:07 am
.||........-# Re: Command-line arguments Christopher Wright 05-Jul-2008 09:32 am
.||........||# Re: Command-line arguments Bruce Adams 05-Jul-2008 09:37 am
.||........|\# Re: Command-line arguments Lars Ivar Igesund 05-Jul-2008 09:40 am
.||........\# Re: Command-line arguments (Current message) superdan 05-Jul-2008 02:50 pm
.|-# Why D Needs Attributes (Was: Command-line arguments) Nick Sabalausky 04-Jul-2008 12:32 am
.||-# Re: Why D Needs Attributes (Was: Command-line arguments) Nick Sabalausky 04-Jul-2008 02:57 am
.|||-# Re: Why D Needs Attributes (Was: Command-line arguments) superdan 04-Jul-2008 03:19 am
.|||.-# Re: Why D Needs Attributes (Was: Command-line arguments) Nick Sabalausky 04-Jul-2008 04:19 am
.|||..|# Re: Why D Needs Attributes (Was: Command-line arguments) Lutger 04-Jul-2008 09:10 am
.|||..-# Re: Why D Needs Attributes (Was: Command-line arguments) superdan 04-Jul-2008 10:37 am
.|||...|# Re: Why D Needs Attributes (Was: Command-line arguments) Nick Sabalausky 04-Jul-2008 03:50 pm
.|||...-# Re: Why D Needs Attributes (Was: Command-line arguments) Robert Fraser 04-Jul-2008 06:16 pm
.|||....-# Re: Why D Needs Attributes (Was: Command-line arguments) superdan 04-Jul-2008 10:31 pm
.|||.....-# Re: Why D Needs Attributes (Was: Command-line arguments) Nick Sabalausky 05-Jul-2008 12:33 am
.|||......-# Re: Why D Needs Attributes (Was: Command-line arguments) Dee Girl 05-Jul-2008 01:05 am
.|||......||# Re: Why D Needs Attributes (Was: Command-line arguments) Robert Fraser 05-Jul-2008 04:49 am
.|||......|\# Re: Why D Needs Attributes (Was: Command-line arguments) Bruce Adams 05-Jul-2008 06:30 am
.|||......\# Re: Why D Needs Attributes (Was: Command-line arguments) superdan 05-Jul-2008 03:20 pm
.||-# Re: Why D Needs Attributes (Was: Command-line arguments) Nick Sabalausky 06-Jul-2008 05:57 pm
.||.-# Re: Why D Needs Attributes (Was: Command-line arguments) Lutger 07-Jul-2008 06:49 am
.||..-# Re: Why D Needs Attributes (Was: Command-line arguments) Nick Sabalausky 07-Jul-2008 01:41 pm
.||...|# Re: Why D Needs Attributes (Was: Command-line arguments) Robert Fraser 07-Jul-2008 04:36 pm
.||...\# Re: Why D Needs Attributes (Was: Command-line arguments) Yigal Chripun 07-Jul-2008 06:16 pm
.|\# Re: Command-line arguments Sean Kelly 04-Jul-2008 10:52 am
.|# Re: Command-line arguments Walter Bright 04-Jul-2008 01:49 am
.\# Re: Command-line arguments Kirk McDonald 04-Jul-2008 08:17 pm