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
4 changes: 2 additions & 2 deletions internal/quickstart/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"context"
"encoding/json"
"fmt"
"os"

tea "github.com/charmbracelet/bubbletea"

"ldcli/internal/environments"
"ldcli/internal/errors"
"ldcli/internal/flags"
"ldcli/internal/sdks"
)

// errMsg is sent when there is an error in one of the steps that the container model needs to
Expand Down Expand Up @@ -114,7 +114,7 @@ func chooseSDK(sdk sdkDetail) tea.Cmd {

func readSDKInstructions(filename string) tea.Cmd {
return func() tea.Msg {
content, err := os.ReadFile(fmt.Sprintf("internal/sdks/sdk_instructions/%s.md", filename))
content, err := sdks.InstructionFiles.ReadFile(fmt.Sprintf("sdk_instructions/%s.md", filename))
if err != nil {
return errMsg{err: err}
}
Expand Down
14 changes: 12 additions & 2 deletions internal/quickstart/show_sdk_instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package quickstart

import (
"fmt"

"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/spinner"
Expand Down Expand Up @@ -32,6 +33,7 @@ type showSDKInstructionsModel struct {
displayName string
environment *environment
environmentsClient environments.Client
err error
flagKey string
help help.Model
helpKeys keyMap
Expand Down Expand Up @@ -63,7 +65,6 @@ func NewShowSDKInstructionsModel(
PaddingRight(2)

h := help.New()
h.ShowAll = true
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.

only showing full help when showing the instructions


return showSDKInstructionsModel{
accessToken: accessToken,
Expand Down Expand Up @@ -129,15 +130,24 @@ func (m showSDKInstructionsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.viewport.SetContent(md)
case spinner.TickMsg:
m.spinner, cmd = m.spinner.Update(msg)
case errMsg:
m.err = msg.err
}

return m, cmd
}

func (m showSDKInstructionsModel) View() string {
if m.err != nil {
return footerView(m.help.View(m.helpKeys), m.err)
}

if m.instructions == "" || m.environment == nil {
return m.spinner.View() + fmt.Sprintf(" Fetching %s SDK instructions...", m.displayName)
return m.spinner.View() + fmt.Sprintf(" Fetching %s SDK instructions...\n", m.displayName) + footerView(m.help.View(m.helpKeys), nil)
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.

added the footer view here as well

}

m.help.ShowAll = true

instructions := fmt.Sprintf(`
Here are the steps to set up a test app to see feature flagging in action
using the %s SDK in your Default project & Test environment.
Expand Down
4 changes: 4 additions & 0 deletions internal/sdks/sdks.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package sdks

import (
"embed"
"regexp"
"strings"
)

//go:embed sdk_instructions/*.md
var InstructionFiles embed.FS

Comment on lines +9 to +11
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.

main change

// ReplaceFlagKey changes the placeholder flag key in the SDK instructions to the flag key from
// the user.
func ReplaceFlagKey(instructions string, key string) string {
Expand Down