On Thursday 12 of May 2011 01:01:10 David Lutterkort wrote: > On Wed, 2011-05-11 at 09:24 +0200, Radek Novacek wrote: > > (resended as I wasn't member of augeas-devel mailing list) > > > > > I was hoping somebody would just cook up a patch based on augtool ;) It > > > shouldn't be much more work than doing it (yet again) for standalone > > > use. > > > > I can try to do it. To be clear, the task is to add method to augeas > > library called e.g. batch, which takes string argument. In this argument > > will be command (or semicolon separated list of commands) same as for > > augtool. What will the method return? True only if all commands > > succeeds, false otherwise? > > All good questions; I initially thought we could just take parts of > augtool.c (roughly run_command and everything it depends on) and put it > behind the API. One of my goals here is that augtool can use this new > API, without any changes in its behavior. > > Besides how to indicate errors, the other question is how to deal with > all the printing to stdout and stderr that the various cmd_* handlers in > augtool.c do right now. One option would be to let the caller pass in > file pointers for that. > > I am thinking we should add two functions to the API: > > int aug_srun(augeas *aug, > const char *text, size_t text_len, > FILE *out, unsigned int flags) > > and > > int aug_frun(augeas *aug, > FILE *in, FILE *out, > unsigned int flags) > > The functions return 0 on success and -1 on error; further details about > the error can be found with aug_error; if that returns AUG_ECOMMAND, > something went wrong with parsing a command. We can use > aug_error_minor_message and aug_error_details to provide more error > information. > > The commands are either read from TEXT (aug_srun) or from IN (aug_frun, > reads till EOF); commands must be separated by newlines. I don't think > there's any point in getting fancy with semicolons. > > If OUT is non-NULL, commands that produce output (e.g. > 'get /augeas/version' or 'print /files/etc/hosts') will print that on > OUT. That way, augtool can just pass stdout and the user should see > output identical to the current output. > > By default, executing commands is aborted when an error is encountered; > by setting FLAGS to AUG_RUN_CONTINUE, errors are ignored as much as > possible (e.g., a syntax error will be ignored, but an OOM would still > lead to returning with an error) > > How does all that sound ? Since this now seems a little more involved > than I first thought, I might have a crack at it tomorrow. Please let me > know if the suggested API's would work for you. > > David
Hi, David, do you have any progress with this feature? I can try to implement it if you are busy. Radek Novacek _______________________________________________ augeas-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/augeas-devel
