Coding guidelines for command-line scripts
We have the beginnings of some coding guidelines for command-line scripts, but it doesn't look like they are firm: http://wiki.koha-community.org/wiki/Coding_Guidelines#Command-line_argument_... I was testing Bug 8674, "Need a delete biblios script" (http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8674), and was frustrated that there was no help option, but was unsure whether that should block the script from getting a signoff. Would everyone agree that new command-line scripts must accept "--help" (and include relevant help, of course) ? Should it also be the standard that command-line scripts should not perform any action unless an argument is passed? Anything else? -- Owen -- Web Developer Athens County Public Libraries http://www.myacpl.org
Greetings,
http://wiki.koha-community.org/wiki/Coding_Guidelines#Command-line_argument_...
Good start, particularly the reference to the gnu link.
[snip] Would everyone agree that new command-line scripts must accept "--help" (and include relevant help, of course) ?
I was thinking perhaps short versions might be considered passable too? So -h would suffice, though --help would be preferred. With GetLongOpts()
Should it also be the standard that command-line scripts should not perform any action unless an argument is passed?
Actually, this is what I like about the koha_perl_deps.pl script. No parameters gives the help, though this is definitely not a normally expected behaviour. +1 for required help parameter. I do like less typing, so I'm not so strict on --help vs. -h. http://www.gnu.org/prep/standards/standards.html#index-CGI-programs_002c-sta... Yet, if this is the standard we want to stick with. I'm okay with it. GPML, Mark Tompsett
Owen, et. al., Would everyone agree that new command-line scripts must accept
"--help" (and include relevant help, of course) ?
+1 Should it also be the standard that command-line scripts should not
perform any action unless an argument is passed?
I like this idea. +1 too Regards, Jared -- Jared Camins-Esakov Bibliographer, C & P Bibliography Services, LLC (phone) +1 (917) 727-3445 (e-mail) jcamins@cpbibliography.com (web) http://www.cpbibliography.com/
Hi, On 08/29/2012 10:14 AM, Owen Leonard wrote:
Would everyone agree that new command-line scripts must accept "--help" (and include relevant help, of course) ?
+1
Should it also be the standard that command-line scripts should not perform any action unless an argument is passed?
+1
Anything else?
Command-line scripts should return an exit code of 0 on success and not-0 on failure. Regards, Galen -- Galen Charlton Director of Support and Implementation Equinox Software, Inc. / The Open Source Experts email: gmc@esilibrary.com direct: +1 770-709-5581 cell: +1 404-984-4366 skype: gmcharlt web: http://www.esilibrary.com/ Supporting Koha and Evergreen: http://koha-community.org & http://evergreen-ils.org
Greetings,
Command-line scripts should return an exit code of 0 on success and not-0 on failure.
This is generally the case and a good rule of thumb, which I support, but there may be cases of exceptions. GREP 0: Found 1: Not Found 2: Error If for some reason the script is grep-like in nature (I'm being hypothetical), then it should return like grep. Generally, scripts won't be, so: +1 for 0=success and not-0=failure. GPML, Mark Tompsett
* Galen Charlton (gmc@esilibrary.com) wrote:
Hi,
On 08/29/2012 10:14 AM, Owen Leonard wrote:
Would everyone agree that new command-line scripts must accept "--help" (and include relevant help, of course) ?
+1
Should it also be the standard that command-line scripts should not perform any action unless an argument is passed?
+1
Anything else?
Command-line scripts should return an exit code of 0 on success and not-0 on failure.
+1 Chris -- Chris Cormack Catalyst IT Ltd. +64 4 803 2238 PO Box 11-053, Manners St, Wellington 6142, New Zealand
On 2012-08-30, at 8:14 AM, Chris Cormack wrote:
* Galen Charlton (gmc@esilibrary.com) wrote:
Hi,
On 08/29/2012 10:14 AM, Owen Leonard wrote:
Would everyone agree that new command-line scripts must accept "--help" (and include relevant help, of course) ?
+1
Should it also be the standard that command-line scripts should not perform any action unless an argument is passed?
+1
Anything else?
Command-line scripts should return an exit code of 0 on success and not-0 on failure.
+1
i'll have a go at writing a test for it :)
Op 29-08-12 16:14, Owen Leonard schreef:
Would everyone agree that new command-line scripts must accept "--help" (and include relevant help, of course) ?
It also should say what it does. Stuff like: $ mcomp --help usage: /usr/bin/mcomp dosfile [cmpoptions] unixfile is bad.
Should it also be the standard that command-line scripts should not perform any action unless an argument is passed?
Probably in general, if it's something that's not reversible, yeah. -- Robin Sheat Catalyst IT Ltd. ✆ +64 4 803 2204 GPG: 5957 6D23 8B16 EFAB FEF8 7175 14D3 6485 A99C EB6D
participants (7)
-
Chris Cormack -
Galen Charlton -
Jared Camins-Esakov -
Mark Tompsett -
Mason James -
Owen Leonard -
Robin Sheat