@@ -24,6 +24,8 @@ import (
2424 "github.com/slackapi/slack-cli/internal/iostreams"
2525 "github.com/slackapi/slack-cli/internal/pkg/create"
2626 "github.com/slackapi/slack-cli/internal/shared"
27+ "github.com/slackapi/slack-cli/internal/style"
28+ "github.com/spf13/pflag"
2729)
2830
2931//go:embed samples.tmpl
@@ -36,13 +38,57 @@ func PromptSampleSelection(ctx context.Context, clients *shared.ClientFactory, s
3638 return "" , err
3739 }
3840
39- projectType := "deno"
40- filteredRepos := filterRepos (sampleRepos , projectType )
41+ projectTypes := []string {}
42+ selection , err := clients .IO .SelectPrompt (ctx , "Select a language:" ,
43+ []string {
44+ fmt .Sprintf ("Bolt for JavaScript %s" , style .Secondary ("Node.js" )),
45+ fmt .Sprintf ("Bolt for Python %s" , style .Secondary ("Python" )),
46+ fmt .Sprintf ("Deno Slack SDK %s" , style .Secondary ("Deno" )),
47+ },
48+ iostreams.SelectPromptConfig {
49+ Flags : []* pflag.Flag {
50+ clients .Config .Flags .Lookup ("language" ),
51+ clients .Config .Flags .Lookup ("template" ), // Skip filtering with a template
52+ },
53+ Required : false ,
54+ },
55+ )
56+ if err != nil {
57+ return "" , err
58+ } else if selection .Prompt {
59+ switch selection .Index {
60+ case 0 :
61+ projectTypes = []string {"bolt-js" , "bolt-ts" }
62+ case 1 :
63+ projectTypes = []string {"bolt-python" }
64+ case 2 :
65+ projectTypes = []string {"deno" }
66+ }
67+ } else if selection .Flag {
68+ switch strings .ToLower (strings .TrimSpace (selection .Option )) {
69+ case "node" :
70+ projectTypes = []string {"bolt-js" , "bolt-ts" }
71+ case "python" :
72+ projectTypes = []string {"bolt-python" }
73+ case "deno" :
74+ projectTypes = []string {"deno" }
75+ default :
76+ projectTypes = []string {selection .Option }
77+ }
78+ }
79+
80+ filteredRepos := []create.GithubRepo {}
81+ if len (projectTypes ) <= 0 {
82+ filteredRepos = sampleRepos
83+ }
84+ for _ , language := range projectTypes {
85+ filteredRepos = append (filteredRepos , filterRepos (sampleRepos , language )... )
86+ }
4187 sortedRepos := sortRepos (filteredRepos )
4288 selectOptions := createSelectOptions (sortedRepos )
4389
4490 var selectedTemplate string
45- selection , err : = clients .IO .SelectPrompt (ctx , "Select a sample to build upon:" , selectOptions , iostreams.SelectPromptConfig {
91+ selection , err = clients .IO .SelectPrompt (ctx , "Select a sample to build upon:" , selectOptions , iostreams.SelectPromptConfig {
4692 Description : func (value string , index int ) string {
4793 return sortedRepos [index ].Description + "\n https://github.com/" + sortedRepos [index ].FullName
4894 },
0 commit comments