File: flag_array.go

package info (click to toggle)
ffcvt 1.7.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 368 kB
  • sloc: sh: 27; makefile: 16
file content (34 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
////////////////////////////////////////////////////////////////////////////
// Porgram: flag_array
// Purpose: a user-defined Go flag type that allows multiple occurrence
// Authors: Tong Sun (c) 2021, All rights reserved
// License: MIT
////////////////////////////////////////////////////////////////////////////
// Refs https://github.com/suntong/lang/blob/master/lang/Go/src/sys/CommandLineFlagArray.go

package main

// mFlags extend Go flags so that it can be specified multiple times
type mFlags []string

func (f *mFlags) String() string {
	return "n.a."
}

func (f *mFlags) Set(value string) error {
	*f = append(*f, value)
	return nil
}

/*

Usage Example:

var multiple mFlags

func main() {
 flag.Var(&multiple, "list1", "Some description for this param.")
 flag.Parse()
}

*/