os.Args simply exposes the arguments passed to the program by the operating
system. On UNIX this is typically called "argv" in C/C++ programs. The
parsing of those strings into two arguments is done by the shell that runs
your elvish program. It is not done by os.Args. I'm not aware of any
functionality in the standard Go runtime that does what you want. There are
probably third-party packages which do it that you could import. Or, roll
your own CLI parser as shown in the stackoverflow question.

On Mon, Apr 20, 2020 at 9:27 AM Michał Łowicki <mlowi...@gmail.com> wrote:

> Hi,
>
> I'm working on a program which will have a prompt to enter commands like:
>
>     add "foo bar"
>
> I need what os.Args provides but on custom input so to above input I would
> like to get:
>
>     []string{"add", "foo bar"}
>
> Package os uses runtime_args(), and it isn't exported nor accepts input.
> Any idea what can I use instead? As a fallback, I can always implement
> something like https://stackoverflow.com/a/46973603, but maybe there is a
> smarter way to do it.
>
> --
> BR,
> Michał Łowicki
>
> --
> 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/CAKu9hcexcyMdjPaWUNd84q0Yhs_PoHCe-jczvhC04vqiU7LPwQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/golang-nuts/CAKu9hcexcyMdjPaWUNd84q0Yhs_PoHCe-jczvhC04vqiU7LPwQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD8yDKak6DR7-7wrm-W40PFEKXTFv-Hn45OqKicft%2BvMVw%40mail.gmail.com.

Reply via email to