Skip to content

Commit e608a7f

Browse files
isaac-fletcherfacebook-github-bot
authored andcommitted
Add create uuid command (facebookincubator#566)
Summary: This exposes the existing UUID generation mechanism used internally by `ttpforge create ttp` as a standalone command for user convenience. While TTPs created with `create ttp` already include an automatically generated UUID, users sometimes need to manually generate UUIDs when manually creating or editing TTP files. Reviewed By: RoboticPrism Differential Revision: D85156307
1 parent bc6f502 commit e608a7f

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

cmd/create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ func buildCreateCommand() *cobra.Command {
3131
TraverseChildren: true,
3232
}
3333
createCmd.AddCommand(buildCreateTTPCommand())
34+
createCmd.AddCommand(buildCreateUUIDCommand())
3435
return createCmd
3536
}

cmd/createuuid.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright © 2023-present, Meta Platforms, Inc. and affiliates
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
The above copyright notice and this permission notice shall be included in
10+
all copies or substantial portions of the Software.
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17+
THE SOFTWARE.
18+
*/
19+
20+
package cmd
21+
22+
import (
23+
"fmt"
24+
25+
"github.com/google/uuid"
26+
"github.com/spf13/cobra"
27+
)
28+
29+
func buildCreateUUIDCommand() *cobra.Command {
30+
createUUIDCmd := &cobra.Command{
31+
Use: "uuid",
32+
Short: "Generate and print a new UUID",
33+
Long: "Generate a new UUID and print it to the console",
34+
RunE: func(cmd *cobra.Command, args []string) error {
35+
newUUID := uuid.New()
36+
fmt.Println(newUUID.String())
37+
return nil
38+
},
39+
}
40+
return createUUIDCmd
41+
}

docs/foundations/create.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ execute your new TTP.
1515
TTPForge will create the specified file and populate it with a skeleton TTP YAML
1616
configuration containing important metadata.
1717

18+
## Generating UUIDs
19+
20+
TTPs created with `create ttp` already include an automatically generated UUID.
21+
However, if you need to manually generate a UUID (for example, when manually
22+
creating or editing TTP files), TTPForge exposes the same UUID generation
23+
mechanism for convenience:
24+
25+
```bash
26+
ttpforge create uuid
27+
```
28+
29+
This will generate and print a new UUID to the console that you can copy and use
30+
in your TTP configuration files.
31+
1832
## Next Steps
1933

2034
Open your new YAML file in your favorite code editor and then check out our

0 commit comments

Comments
 (0)