[Koha-devel] Conventions for CLI scripts

Mark Tompsett mtompset at hotmail.com
Thu Sep 18 15:29:42 CEST 2014


Greetings,

>     1. There are two directions for this:
>             I. By default the action will be performed, unless you add
>                an argument (--dry-run for example.)
>            II. By default the action will not be performed, unless you
>                add an argument (--commit for example.)

If you run a script called DestroyTheDatabase, you would expect the default 
action to be complete and utter deletion. I think a dry-run flag would make 
sense for this type of script. The problem is those scripts whose name is 
not indicative of DB modifications. I suspect you are thinking about 
checkNonIndexedBiblios.pl which only runs if you include -c, much like point 
1 subsection II. The name doesn't suggest default modifications. In this 
case, you have to add the -z which will then insert the non-indexed Biblios 
into the zebra queue. This is like the second method. Can we have a mix? 
Does a mix make any sense?

This kind of reminds me of the help for scripts issues I was wondering 
about. I see a script name, other than reading the code, how do I get a 
sample use page? Do we force help on users if no parameters are passed? Do 
we expect a particular letter or 
phrase? --help -h --usage --examples --something-else? 
checkNonIndexedBiblios.pl does it both ways.


>     2. What do we want to call the options, whichever way is picked?
>             I. Keeping in mind that some things (-c for example) can
>                conflict with other conventions.

Are there different conventions to choose from? How does Debian (Ubuntu, 
etc.) do it?


>     3. Are there any other conventions we should deal with at the same
>        time?

None of which I am aware.

[SNIP]
+1 on the turning off  auto-commit, so dry runs do the same as actual runs.
+1 on the explicit rollback or commit.


>        $dbi->begin_work;

Actually, I guess that is a nicer way of doing this?

# Start transaction
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;

GPML,
Mark Tompsett 



More information about the Koha-devel mailing list