Thread: Re: [Autogen-users] AutoOpts for Shell-Script
Brought to you by:
bkorb
From: Bruce K. <bru...@gm...> - 2012-12-14 22:06:37
|
Hi Manuel, > I want to use AutoOpts for Shell script generation, and in previous > letters Bruce already introduced me on how to compile the def-file so a > shell script is created. Bruce has forgotten which flavor, since you can either produce shell script or a binary option processing "partner", a la: opts=`${0}-opts ${1+"$@"}` eval "$opts" case "X${OPTION_CT}" in X ) exit 1 ;; X0 ) : ;; * ) shift ${OPTION_CT} ;; esac or source or auto-edit in the generated script: . ${0}-opts.sh ${1+"$@"} > Now i want to to modify the shell script found at > https://github.com/codeless/MyRex/blob/master/myrex.sh to use AutoOpts. > Several parameters for this script are forced, but this doesn't seem to > work with AutoOpts. For instance: > > flag = { > name = sqlfile; > descrip = "SQL file to be executed"; > arg-type = file; > must-set = true; > } > > I want AutoOpts to check for the parameter "sqlfile", which has to be > set and should be checked if it's a valid (existing) file. How to > achieve this? Is it possible with AutoOpts for Shell-Scripts? That is done with a companion binary, but I don't know if I did that for the emitted shell script. It would be reasonable to check the minimum count/must-set status and emit appropriate code. I am certain I haven't done it for "must-set", I might have for "min = 1". "must-set" is only 6 or 7 years old. > Further on, i want to force the user to pass a directory-path to the > script (not as flag); i used: > > argument = file; > > Is this the way to go? That is the way to go. Is it actually implemented? That is a completely different question. Since "file" arguments are something from the last few years and I haven't done much with shell script stuff for close to a decade, (Parts of makeshell.c file havn't been touched in 14 years. :) I'm pretty sure that no verifications get inserted into the script. If you are willing and able to have a binary option parser program, you'd get more consistency and easier support. Otherwise, for fastest support, you'd be most welcome to fiddle the code in autoopts/makeshell.c and the various strings it uses in autoopts/ao-strs.def. > Thanks for any help!! I'd be thanking -you-! :) Cheers - Bruc |
From: Manuel H <mo...@co...> - 2012-12-15 11:38:13
|
Hello Bruce! Thanks for your kind answer and the tip which C-file to edit. Unfortunately i'm not very comfortable with C at the time of writing this. Also, i feel it complicates things when i have to create a binary which creates my shell-script for checking the arguments. (My goal is to use AutoOpts for argument checking of shell scripts.) So my idea is to create a AutoGen template for AutoOpts, which allows the creation of shell-scripts (i will create the necessary template(s)). What do you think? Could such a template become part of AutoOpts? All the best, -Manuel |
From: Bruce K. <bru...@gm...> - 2012-12-16 13:48:57
|
Hi Manuel, On Sat, Dec 15, 2012 at 3:37 AM, Manuel H <mo...@co...> wrote: > Hello Bruce! > > Thanks for your kind answer and the tip which C-file to edit. > Unfortunately i'm not very comfortable with C at the time of writing > this. Also, i feel it complicates things when i have to create a binary > which creates my shell-script for checking the arguments. (My goal is to > use AutoOpts for argument checking of shell scripts.) > > So my idea is to create a AutoGen template for AutoOpts, which allows > the creation of shell-scripts (i will create the necessary template(s)). > What do you think? Could such a template become part of AutoOpts? Definitely. I'd probably obsolete the "makeshell" code, in fact. I think it is a better approach, but 14 years ago "makeshell.c" seemed easier. :) |
From: Bruce K. <bru...@gm...> - 2012-12-17 18:29:15
|
On 12/15/12 03:37, Manuel H wrote: > Hello Bruce! > > Thanks for your kind answer and the tip which C-file to edit. You're welcome. > Unfortunately i'm not very comfortable with C at the time of writing OK, I spent a couple of hours at it this weekend. (Expected 1, took 2.) Please give http://autogen.sourceforge.net/data/autogen-5.17.0pre11.tar.xz a spin. It validates the min/max occurrences. "must-set", by the way, is intended to ensure that a setting (option) has been set either on the command line or in a config file, whereas "min = 1" says it has to be on the command line. Shell scripts should not be making such a distinction, so I think you want "min = 1" in your def file. In any event, for a shell script, "must-set" now implies a min of 1 when min is unspecified or even specified as 0 (zero). > So my idea is to create a AutoGen template for AutoOpts, which allows > the creation of shell-scripts (i will create the necessary template(s)). > What do you think? Could such a template become part of AutoOpts? I still think this is the best solution, but someone other than me will have to have the time to do it (a few 10's of hours). Cheers - Bruce |
From: Manuel H <mo...@co...> - 2012-12-20 17:57:57
|
Hello Bruce! Thanks for the update! > > So my idea is to create a AutoGen template for AutoOpts, which allows > > the creation of shell-scripts (i will create the necessary template(s)). > > What do you think? Could such a template become part of AutoOpts? > > I still think this is the best solution, but someone other than me > will have to have the time to do it (a few 10's of hours). Well, i'll do it. I'm thinking of github.com as the platform to share the AutoGen Shell Script template. I'll name the repository AutoShell or the like. I hope that's fine with you? Cheers, Manuel |