Re: [go-nuts] How to have a raw parameter value in cobra?

2024-02-25 Thread David Karr
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  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 " 
>   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  
> 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:
> >> >
> >> >
> >> >
> >> > 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.


Re: [go-nuts] How to have a raw parameter value in cobra?

2024-02-25 Thread burak serdar
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  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 " 
>   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  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:
>> >
>> >
>> >
>> > 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+unsubscr...@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/CAMV2RqoOs2TacBQ6iLxybwP6Wv74WDmTUk%2B2WR2kYFKmJQrFoQ%40mail.gmail.com.


Re: [go-nuts] How to have a raw parameter value in cobra?

2024-02-25 Thread David Karr
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 " 
  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  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:
> >
> >
> >
> > 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+unsubscr...@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.


Re: [go-nuts] How to have a raw parameter value in cobra?

2024-02-25 Thread burak serdar
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  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:
>
>
>
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqrshNcSUdBiMrCTP8GkEc3mHre3eBXN2W%2BK%3DDiwoiWvCQ%40mail.gmail.com.