Skip to content

Commit

Permalink
chore: update pdk names to be better for display
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslice committed Apr 2, 2024
1 parent 04342d0 commit 6d5acc2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
15 changes: 8 additions & 7 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
var templatesData []byte

type pdkTemplate struct {
Pdk string `json:"pdk"`
Url string `json:"url"`
Name string `json:"name"`
Url string `json:"url"`
}

func GenerateCmd() *cobra.Command {
Expand Down Expand Up @@ -67,7 +67,7 @@ func generatePlugin(lang string, dir string) error {
var match bool
var pdk pdkTemplate
for _, tmpl := range templates {
if strings.ToLower(tmpl.Pdk) == lang {
if strings.ToLower(tmpl.Name) == lang {
match = true
pdk = tmpl
break
Expand All @@ -89,6 +89,7 @@ func generatePlugin(lang string, dir string) error {
}

func cloneTemplate(pdk pdkTemplate, dir string) error {
fmt.Println(pdk.Url)
cloneCmd := exec.Command("git", "clone", pdk.Url, dir)
cloneCmd.Stdout = os.Stdout
cloneCmd.Stderr = os.Stderr
Expand All @@ -113,7 +114,7 @@ func cloneTemplate(pdk pdkTemplate, dir string) error {
return err
}

fmt.Println("Generated", pdk.Pdk, "plugin scaffold at", dir)
fmt.Println("Generated", pdk.Name, "plugin scaffold at", dir)

return nil
}
Expand Down Expand Up @@ -194,7 +195,7 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

func (m *model) View() string {
if m.choice != "" {
return quitTextStyle.Render(fmt.Sprintf("Generating scaffold for plugin using %s-pdk...", m.choice))
return quitTextStyle.Render(fmt.Sprintf("Generating scaffold for plugin using %s...", m.choice))
}
if m.quitting {
return "Operation cancelled."
Expand All @@ -206,8 +207,8 @@ func pickPdk(pdks []pdkTemplate) pdkTemplate {
pdkMap := make(map[string]pdkTemplate, len(pdks))
var items []list.Item
for _, pdk := range pdks {
pdkMap[pdk.Pdk] = pdk
items = append(items, item(pdk.Pdk))
pdkMap[pdk.Name] = pdk
items = append(items, item(pdk.Name))
}

const defaultWidth = 20
Expand Down
18 changes: 9 additions & 9 deletions pdk-templates.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[
{
"pdk": "rust",
"name": "Rust",
"url": "https://github.com/extism/rust-pdk-template"
},
{
"pdk": "javascript",
"name": "JavaScript",
"url": "https://github.com/extism/javascript-pdk-template"
},
{
"pdk": "go",
"name": "Go",
"url": "https://github.com/extism/go-pdk-template"
},
{
"pdk": "zig",
"name": "Zig",
"url": "https://github.com/extism/zig-pdk-template"
},
{
"pdk": "c-sharp",
"name": "C#",
"url": "https://github.com/extism/c-sharp-pdk-template"
},
{
"pdk": "f-sharp",
"name": "F#",
"url": "https://github.com/extism/f-sharp-pdk-template"
},
{
"pdk": "c",
"name": "C",
"url": "https://github.com/extism/c-pdk-template"
},
{
"pdk": "haskell",
"name": "Haskell",
"url": "https://github.com/extism/haskell-pdk-template"
},
{
"pdk": "assemblyscript",
"name": "AssemblyScript",
"url": "https://github.com/extism/assemblyscript-pdk-template"
}
]

0 comments on commit 6d5acc2

Please sign in to comment.