Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions internal/quickstart/choose_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ type sdkDetail struct {
func (s sdkDetail) FilterValue() string { return "" }

var SDKs = []sdkDetail{
// TODO: react is still internal
// {CanonicalName: "react", DisplayName: "React", SDKType: clientSideSDK},
{canonicalName: "react", displayName: "React", kind: clientSideSDK},
{canonicalName: "node-server", displayName: "Node.js (server-side)", kind: serverSideSDK},
{canonicalName: "python", displayName: "Python", kind: serverSideSDK},
{canonicalName: "java", displayName: "Java", kind: serverSideSDK},
Expand Down
4 changes: 4 additions & 0 deletions internal/quickstart/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ func (m ContainerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
case errMsg:
m.err = msg.err
case noInstructionsMsg:
m.currentStep += 1

return m, cmd
default:
}

Expand Down
11 changes: 11 additions & 0 deletions internal/quickstart/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type fetchSDKInstructionsMsg struct {
name string
}

// errMsg is sent when there is an error in one of the steps that the container model needs to
// know about.
type errMsg struct {
err error
}
Expand All @@ -17,3 +19,12 @@ func sendErr(err error) tea.Cmd {
return errMsg{err: err}
}
}

// noInstructionsMsg is sent when we can't find the SDK instructions repository for the given SDK.
type noInstructionsMsg struct{}

func sendNoInstructions() tea.Cmd {
return func() tea.Msg {
return noInstructionsMsg{}
}
}
11 changes: 5 additions & 6 deletions internal/quickstart/show_sdk_instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package quickstart
import (
"fmt"
"io"
"ldcli/internal/errors"
"ldcli/internal/sdks"
"net/http"
"time"
Expand Down Expand Up @@ -51,14 +50,14 @@ func (m showSDKInstructionsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, sendErr(err)
}

if resp.StatusCode != 200 {
return m, sendErr(errors.NewError(fmt.Sprintf("could not find %s SDK instructions", msg.name)))
}
if resp.StatusCode == 404 {
m.sdk = msg.name
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need the SDK set, but it couldn't hurt.


instructions := sdks.ReplaceFlagKey(string(body), msg.flagKey)
return m, sendNoInstructions()
}

m.sdk = msg.name
m.instructions = instructions
m.instructions = sdks.ReplaceFlagKey(string(body), msg.flagKey)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined this function call.

}

return m, nil
Expand Down