MCPcopy Create free account
hub / github.com/driangle/taskmd / outputNextIDJSON

Function outputNextIDJSON

apps/cli/internal/cli/nextid.go:84–115  ·  view source on GitHub ↗
(ids []string, cfg validator.IDConfig)

Source from the content-addressed store, hash-verified

82}
83
84func outputNextIDJSON(ids []string, cfg validator.IDConfig) error {
85 switch cfg.Strategy {
86 case "prefixed":
87 id := nextid.GeneratePrefixed(ids, cfg.Prefix, cfg.Padding)
88 return WriteJSON(os.Stdout, nextid.Result{
89 NextID: id,
90 Prefix: cfg.Prefix,
91 Padding: cfg.Padding,
92 Total: len(ids),
93 })
94 case "random":
95 id, err := nextid.GenerateRandom(ids, cfg.Length)
96 if err != nil {
97 return err
98 }
99 return WriteJSON(os.Stdout, nextid.Result{
100 NextID: id,
101 Total: len(ids),
102 })
103 case "ulid":
104 id, err := nextid.GenerateULID(ids, cfg.Length)
105 if err != nil {
106 return err
107 }
108 return WriteJSON(os.Stdout, nextid.Result{
109 NextID: id,
110 Total: len(ids),
111 })
112 default:
113 return WriteJSON(os.Stdout, nextid.Calculate(ids))
114 }
115}

Callers 1

runNextIDFunction · 0.85

Calls 1

WriteJSONFunction · 0.85

Tested by

no test coverage detected