Skip to content

Commit

Permalink
feat: add 'terminal' to module definition to allow simple external mo…
Browse files Browse the repository at this point in the history
…duels to run in terminal
  • Loading branch information
abenz1267 committed Jul 14, 2024
1 parent b02061f commit 3246abb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type Module struct {
SpecialLabel string `json:"special_label,omitempty"`
History bool `json:"history,omitempty"`
SwitcherExclusive bool `json:"switcher_exclusive,omitempty"`
Terminal bool `json:"terminal,omitempty"`
}

type Search struct {
Expand Down
11 changes: 7 additions & 4 deletions modules/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type External struct {
cmd string
switcherExclusive bool
recalculateScore bool
terminal bool
}

func (e External) SwitcherExclusive() bool {
Expand All @@ -37,6 +38,7 @@ func (e External) Setup(cfg *config.Config) Workable {
e.switcherExclusive = module.SwitcherExclusive
e.src = module.Src
e.cmd = module.Cmd
e.terminal = module.Terminal

return e
}
Expand Down Expand Up @@ -104,10 +106,11 @@ func (e External) Entries(ctx context.Context, term string) []Entry {
}

e := Entry{
Label: unescaped,
Sub: e.ModuleName,
Class: e.ModuleName,
Exec: strings.ReplaceAll(e.cmd, "%RESULT%", txt),
Label: unescaped,
Sub: e.ModuleName,
Class: e.ModuleName,
Terminal: e.terminal,
Exec: strings.ReplaceAll(e.cmd, "%RESULT%", txt),
}

if !hasExplicitResult {
Expand Down

0 comments on commit 3246abb

Please sign in to comment.