github.com/hashicorp/packer@v1.14.3/command/flag-slice/flag.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package sliceflag
     5  
     6  import "strings"
     7  
     8  // StringFlag implements the flag.Value interface and allows multiple
     9  // calls to the same variable to append a list.
    10  type StringFlag []string
    11  
    12  func (s *StringFlag) String() string {
    13  	return strings.Join(*s, ",")
    14  }
    15  
    16  func (s *StringFlag) Set(value string) error {
    17  	*s = append(*s, strings.Split(value, ",")...)
    18  	return nil
    19  }