feat: copy config file path
This commit is contained in:
parent
a1c7eb640a
commit
223b7fcd83
@ -21,6 +21,7 @@ type RunParams struct {
|
|||||||
DockerClient container.DockerClient
|
DockerClient container.DockerClient
|
||||||
Screen tcell.Screen
|
Screen tcell.Screen
|
||||||
ClipboardAvailable bool
|
ClipboardAvailable bool
|
||||||
|
ConfigFilePath string
|
||||||
BuildInfo domain.BuildInfo
|
BuildInfo domain.BuildInfo
|
||||||
Logger *slog.Logger
|
Logger *slog.Logger
|
||||||
}
|
}
|
||||||
@ -33,6 +34,7 @@ func Run(ctx context.Context, params RunParams) error {
|
|||||||
ui, err := terminal.StartUI(ctx, terminal.StartParams{
|
ui, err := terminal.StartUI(ctx, terminal.StartParams{
|
||||||
Screen: params.Screen,
|
Screen: params.Screen,
|
||||||
ClipboardAvailable: params.ClipboardAvailable,
|
ClipboardAvailable: params.ClipboardAvailable,
|
||||||
|
ConfigFilePath: params.ConfigFilePath,
|
||||||
BuildInfo: params.BuildInfo,
|
BuildInfo: params.BuildInfo,
|
||||||
Logger: logger.With("component", "ui"),
|
Logger: logger.With("component", "ui"),
|
||||||
})
|
})
|
||||||
|
1
main.go
1
main.go
@ -85,6 +85,7 @@ func run(ctx context.Context) error {
|
|||||||
Config: cfg,
|
Config: cfg,
|
||||||
DockerClient: dockerClient,
|
DockerClient: dockerClient,
|
||||||
ClipboardAvailable: clipboardAvailable,
|
ClipboardAvailable: clipboardAvailable,
|
||||||
|
ConfigFilePath: configService.Path(),
|
||||||
BuildInfo: domain.BuildInfo{
|
BuildInfo: domain.BuildInfo{
|
||||||
GoVersion: buildInfo.GoVersion,
|
GoVersion: buildInfo.GoVersion,
|
||||||
Version: buildInfo.Main.Version,
|
Version: buildInfo.Main.Version,
|
||||||
|
@ -62,6 +62,7 @@ type StartParams struct {
|
|||||||
ChanSize int
|
ChanSize int
|
||||||
Logger *slog.Logger
|
Logger *slog.Logger
|
||||||
ClipboardAvailable bool
|
ClipboardAvailable bool
|
||||||
|
ConfigFilePath string
|
||||||
BuildInfo domain.BuildInfo
|
BuildInfo domain.BuildInfo
|
||||||
Screen tcell.Screen
|
Screen tcell.Screen
|
||||||
}
|
}
|
||||||
@ -135,7 +136,8 @@ func StartUI(ctx context.Context, params StartParams) (*UI, error) {
|
|||||||
aboutView.SetBorder(true)
|
aboutView.SetBorder(true)
|
||||||
aboutView.SetTitle("Actions")
|
aboutView.SetTitle("Actions")
|
||||||
aboutView.AddItem(tview.NewTextView().SetText("[Space] Toggle destination"), 1, 0, false)
|
aboutView.AddItem(tview.NewTextView().SetText("[Space] Toggle destination"), 1, 0, false)
|
||||||
aboutView.AddItem(tview.NewTextView().SetText("[C] Copy ingress RTMP URL"), 1, 0, false)
|
aboutView.AddItem(tview.NewTextView().SetText("[u] Copy ingress RTMP URL"), 1, 0, false)
|
||||||
|
aboutView.AddItem(tview.NewTextView().SetText("[c] Copy config file path"), 1, 0, false)
|
||||||
aboutView.AddItem(tview.NewTextView().SetText("[?] About"), 1, 0, false)
|
aboutView.AddItem(tview.NewTextView().SetText("[?] About"), 1, 0, false)
|
||||||
|
|
||||||
sidebar.AddItem(aboutView, 0, 1, false)
|
sidebar.AddItem(aboutView, 0, 1, false)
|
||||||
@ -184,8 +186,10 @@ func StartUI(ctx context.Context, params StartParams) (*UI, error) {
|
|||||||
switch event.Rune() {
|
switch event.Rune() {
|
||||||
case ' ':
|
case ' ':
|
||||||
ui.toggleDestination()
|
ui.toggleDestination()
|
||||||
case 'c', 'C':
|
case 'u', 'U':
|
||||||
ui.copySourceURLToClipboard(params.ClipboardAvailable)
|
ui.copySourceURLToClipboard(params.ClipboardAvailable)
|
||||||
|
case 'c', 'C':
|
||||||
|
ui.copyConfigFilePathToClipboard(params.ClipboardAvailable, params.ConfigFilePath)
|
||||||
case '?':
|
case '?':
|
||||||
ui.showAbout()
|
ui.showAbout()
|
||||||
}
|
}
|
||||||
@ -522,9 +526,32 @@ func (ui *UI) toggleDestination() {
|
|||||||
|
|
||||||
func (ui *UI) copySourceURLToClipboard(clipboardAvailable bool) {
|
func (ui *UI) copySourceURLToClipboard(clipboardAvailable bool) {
|
||||||
var text string
|
var text string
|
||||||
|
|
||||||
|
url := ui.sourceViews.url.GetText(true)
|
||||||
if clipboardAvailable {
|
if clipboardAvailable {
|
||||||
clipboard.Write(clipboard.FmtText, []byte(ui.sourceViews.url.GetText(true)))
|
clipboard.Write(clipboard.FmtText, []byte(url))
|
||||||
text = "Ingress URL copied to clipboard"
|
text = "Ingress URL copied to clipboard:\n\n" + url
|
||||||
|
} else {
|
||||||
|
text = "Copy to clipboard not available:\n\n" + url
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.showModal(
|
||||||
|
modalGroupClipboard,
|
||||||
|
text,
|
||||||
|
[]string{"Ok"},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ui *UI) copyConfigFilePathToClipboard(clipboardAvailable bool, configFilePath string) {
|
||||||
|
var text string
|
||||||
|
if clipboardAvailable {
|
||||||
|
if configFilePath != "" {
|
||||||
|
clipboard.Write(clipboard.FmtText, []byte(configFilePath))
|
||||||
|
text = "Configuration file path copied to clipboard:\n\n" + configFilePath
|
||||||
|
} else {
|
||||||
|
text = "Configuration file path not set"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
text = "Copy to clipboard not available"
|
text = "Copy to clipboard not available"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user