Ok, that worked. I had tried that before, but I had done it wrong.

On Sunday, February 25, 2024 at 1:04:10 PM UTC-8 burak serdar wrote:

> Somewhere in your main, you should be calling rootCmd.Execute(). Instead:
>
> func main() {
> // first, make sure there are at least 2 args. Then, process the
> 1st parameter
> // Then
> rootCmd.SetArgs(os.Args[2:])
> rootCmd.Execute()
> }
>
> On Sun, Feb 25, 2024 at 1:50 PM David Karr <davidmic...@gmail.com> wrote:
> >
> > But where would that be done? I'm not certain of the exact role of the 
> "rootCmd.Execute()" function, or the optional "Run" function in the Command 
> object. Neither of those appear to be executed, when I just run "<app> 
> <param> <subcommand"". I put a print statement in the "Run" function in the 
> subcommand, and that gets printed, but nothing else.
> >
> > On Sunday, February 25, 2024 at 10:52:10 AM UTC-8 burak serdar wrote:
> >>
> >> You can do rootCmd.SetArgs(os.Args[2:]), and process the first
> >> parameter yourself.
> >>
> >> On Sun, Feb 25, 2024 at 11:43 AM David Karr <davidmic...@gmail.com> 
> wrote:
> >> >
> >> > I am not a new programmer, but I am pretty new to golang, having only 
> written a couple of small applications, and that was several months ago. 
> I'm trying to construct an application using Cobra, using some nonstandard 
> conventions. Is it better to ask a question like this in an issue in the 
> Cobra github site?
> >> >
> >> > The application I am trying to write will be used extremely often, 
> and I want to minimize the required syntax.
> >> >
> >> > I want to set up a command line like the following:
> >> >
> >> > <applicationname> <parameter> <subcommand> <parameters>
> >> >
> >> > The parameter right after the application name will always be 
> present. I don't want it to be a flag. After that parameter value will be a 
> subcommand, followed by additional parameters, also not flags. There are 
> some situations where I want to allow for flags, but that will be uncommon.
> >> >
> >> > It's not clear to me how to cleanly set up this organization. Is it 
> simply not practical to do with Cobra? Should I just do ad hoc parameter 
> processing?
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google 
> Groups "golang-nuts" group.
> >> > To unsubscribe from this group and stop receiving emails from it, 
> send an email to golang-nuts...@googlegroups.com.
> >> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/14b9efb1-7fbb-45a6-8e0e-56f25be310a3n%40googlegroups.com
> .
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "golang-nuts" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to golang-nuts...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/9d8fac62-f70a-488d-8bf9-7800b5d44d34n%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c18c9fe2-c85e-49b9-a3f9-167a8c2236f5n%40googlegroups.com.

Reply via email to