Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to escape "," in StringSliceValue #1552

Closed
kameshsampath opened this issue Oct 29, 2022 · 2 comments
Closed

How to escape "," in StringSliceValue #1552

kameshsampath opened this issue Oct 29, 2022 · 2 comments
Labels
area/v2 relates to / is being considered for v2 kind/question someone asking a question status/triage maintainers still need to look into this

Comments

@kameshsampath
Copy link

I am trying to see if the , can be used as such when present in a flag value .

e.g.

package main

import (
	"log"
	"os"

	"github.com/urfave/cli/v2"
)

func main() {
	var cacheFrom cli.StringSlice
	app := &cli.App{
		Flags: []cli.Flag{
			&cli.StringSliceFlag{
				Name:        "cache-from",
				Usage:       "images to consider as cache sources",
				Destination: &cacheFrom,
			},
		},
		Action: func(c *cli.Context) error {
			log.Printf("Flag %s", cacheFrom.Value())
			for _, arg := range cacheFrom.Value() {
				log.Printf("Cache --> %s", arg)
			}
			return nil
		},
	}

	if err := app.Run(os.Args); err != nil {
		log.Fatal(err)
	}
}

when run go run main.go --cache-from='type=registry,registry=example/foo' I see the following output,

2022/10/29 19:11:53 Flag [type=registry registry=example/foo]
2022/10/29 19:11:53 Cache --> type=registry
2022/10/29 19:11:53 Cache --> registry=example/foo

Ideally I don't expect the value to be split by ,.

Is this bug or there is way to configure it ?

This causing another lib that uses CLI to fail thegeeklab/drone-docker-buildx#141

@kameshsampath kameshsampath added area/v2 relates to / is being considered for v2 kind/question someone asking a question status/triage maintainers still need to look into this labels Oct 29, 2022
@dearchap
Copy link
Contributor

@kameshsampath PR #1546 has a fix for this. It allows you to set the separator to something else. The PR has been merged but release has not been tagged yet. It should be out any day now.

@kameshsampath
Copy link
Author

super thanks @dearchap , looking forward to it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v2 relates to / is being considered for v2 kind/question someone asking a question status/triage maintainers still need to look into this
Projects
None yet
Development

No branches or pull requests

2 participants