comp.lang.ada
 help / color / mirror / Atom feed
From: mockturtle <framefritti@gmail.com>
Subject: Re: GCLP (Generic Command Line Parser) 1.0.0 released
Date: Sat, 15 Dec 2012 10:08:05 -0800 (PST)
Date: 2012-12-15T10:08:05-08:00	[thread overview]
Message-ID: <142eeaa9-839c-412e-8eec-c7aff4ef8b8b@googlegroups.com> (raw)
In-Reply-To: <op.wpdaph0qule2fv@cardamome>

On Saturday, December 15, 2012 5:57:07 PM UTC+1, Hibou57 (Yannick Duchêne) wrote:
> Le Sat, 15 Dec 2012 17:20:19 +0100, mockturtle <framefritti@gmail.com> a  
> 
> écrit:
> 
> > I agree that this differentiates itself from the usual syntax.  I choose  
> 
> > this approach (and wrote this package) once that I needed to write a  
> 
> > program with a fairly complex syntax and with many possible variations.
> 
> 
> 
> If the command line become too complex, that may suggest the command is  
> 
> not well suited for the matter. May be a configuration file or project  
> 
> file, using XML, could be an option. Compare this to some program in some  
> 
> wrong language, becoming unmaintainable, suggesting to use another one.
> 

Yes, I understand, but between a simple command like

      cp src dst

and a command that makes it convenient to give parameters via a configuration file (maybe in XML format), there is a gray area where a positional syntax is too complex (was the port number the first parameter?  or the third?), but the complexity of a configuration file is not justified (maybe also because you use the command only once). In that gray area a syntax like this, in my opinion, becomes convenient.  

I like this syntax also because it makes calls in  shell scripts a bit more readable. As a quasi-real life example, recently we wrote a program that takes a directory full of images, process them and write the result in another directory.  A (more or less) realistic call for this program could be

  process  input-dir=/foo/bar zoom=9 area=128x128 output-dir=/bar/foo

this is a bit more readable (inside a script) than

  process  /foo/bar /bar/foo 9 128x128 

Of course, if you prefer more standard names like "--input-dir", you can use them.

> 
> 
> The command line is not the place for a complex syntax (except if it's an  
> 
> interactive shell, and still with quickly reached limits…).
> 
> 

The example above shows what I mean with "complex syntax" (maybe it is not a perfect choice of words): a command that requires a fair number of parameters (say, more than 3-4), some of which can be optional.  If the syntax was such that you need to express, say, conditionals or complex dependencies between parameters (the command line syntax of VLC comes to my mind :-/), then I agree that a structured configuration file is way better (but not in XML, please! :-) I hate to parse XML... :-) [even with specialized libraries].

> 
> 
> 
> -- 
> 
> “Syntactic sugar causes cancer of the semi-colons.” [1]
> 
> “Structured Programming supports the law of the excluded muddle.” [1]
> 
> [1]: Epigrams on Programming — Alan J. — P. Yale University



  reply	other threads:[~2012-12-15 18:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-14 21:17 GCLP (Generic Command Line Parser) 1.0.0 released mockturtle
2012-12-14 23:33 ` Yannick Duchêne (Hibou57)
2012-12-15 16:20   ` mockturtle
2012-12-15 16:57     ` Yannick Duchêne (Hibou57)
2012-12-15 18:08       ` mockturtle [this message]
2012-12-18 15:33         ` Brian Drummond
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox