MCPcopy
hub / github.com/segmentio/ksuid / main

Function main

cmd/ksuid/main.go:31–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31func main() {
32 flag.Parse()
33 args := flag.Args()
34
35 var print func(ksuid.KSUID)
36 switch format {
37 case "string":
38 print = printString
39 case "inspect":
40 print = printInspect
41 case "time":
42 print = printTime
43 case "timestamp":
44 print = printTimestamp
45 case "payload":
46 print = printPayload
47 case "raw":
48 print = printRaw
49 case "template":
50 print = printTemplate
51 default:
52 fmt.Println("Bad formatting function:", format)
53 os.Exit(1)
54 }
55
56 if len(args) == 0 {
57 for i := 0; i < count; i++ {
58 args = append(args, ksuid.New().String())
59 }
60 }
61
62 var ids []ksuid.KSUID
63 for _, arg := range args {
64 id, err := ksuid.Parse(arg)
65 if err != nil {
66 fmt.Printf("Error when parsing %q: %s\n\n", arg, err)
67 flag.PrintDefaults()
68 os.Exit(1)
69 }
70 ids = append(ids, id)
71 }
72
73 for _, id := range ids {
74 if verbose {
75 fmt.Printf("%s: ", id)
76 }
77 print(id)
78 }
79}
80
81func printString(id ksuid.KSUID) {
82 fmt.Println(id.String())

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
ParseFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…