refactor(commands): separate commands and its core into two folders (#32)

- I think it would be better if one for commands only, one for the spec
handling core logic so people won't be confused by the core logic inside
the commands folder (cleaner I guess)
- Regen docs
This commit is contained in:
VERSE
2026-07-05 11:27:30 +07:00
committed by GitHub
parent 6b98455957
commit ebde9ba68f
536 changed files with 2241 additions and 2241 deletions
+7 -7
View File
@@ -3,33 +3,33 @@ package root
import (
"strings"
"github.com/versenilvis/iris/commands/core"
"github.com/versenilvis/iris/spec"
"github.com/versenilvis/iris/config"
"github.com/versenilvis/iris/integration"
"github.com/versenilvis/iris/logger"
)
// MergeResults collects and dedupes suggestions for a query and mode
func MergeResults(query string, mode string) []core.Suggestion {
func MergeResults(query string, mode string) []spec.Suggestion {
maxSugg := config.Get().UI.MaxSuggestions
seen := make(map[string]bool)
deduped := []core.Suggestion{}
deduped := []spec.Suggestion{}
// always call lookup to scan aliases and get spec suggestions
logger.Debugf("Merge Calling Lookup for '%s'", query)
cmdResults := core.Lookup(query)
cmdResults := spec.Lookup(query)
// search history if in history mode
var histResults []integration.HistResult
if mode == "history" {
aliases := core.GetAliasesCopy()
aliases := spec.GetAliasesCopy()
histResults, _ = integration.SearchHistory(query, aliases)
}
normalizedQuery := strings.TrimSpace(query)
// add suggestion helper to deduplicate
addSuggestion := func(s core.Suggestion) {
addSuggestion := func(s spec.Suggestion) {
normalizedCmd := strings.TrimSpace(s.Cmd)
if normalizedCmd == "" {
return
@@ -47,7 +47,7 @@ func MergeResults(query string, mode string) []core.Suggestion {
if mode == "history" {
// history mode: history first, then spec/alias
for _, h := range histResults {
addSuggestion(core.Suggestion{
addSuggestion(spec.Suggestion{
Cmd: h.Cmd,
Desc: "history",
Icon: "history",
+6 -6
View File
@@ -17,7 +17,7 @@ import (
"time"
"github.com/creack/pty"
"github.com/versenilvis/iris/commands/core"
"github.com/versenilvis/iris/spec"
"github.com/versenilvis/iris/config"
"github.com/versenilvis/iris/integration"
"github.com/versenilvis/iris/integration/shell"
@@ -118,7 +118,7 @@ func runWrapper() {
defer func() { _ = ptmx.Close() }()
_ = pty.InheritSize(os.Stdin, ptmx)
core.ShellPID = c.Process.Pid
spec.ShellPID = c.Process.Pid
logger.Infof("PTY child shell started: shell=%s, path=%s, pid=%d", shellName, adapter.GetShellPath(), c.Process.Pid)
@@ -216,9 +216,9 @@ func runWrapper() {
pendingUpdate = startBackgroundUpdateCheck()
updatePrinted := false
shellPGID, err := unix.Getpgid(core.ShellPID)
shellPGID, err := unix.Getpgid(spec.ShellPID)
if err != nil {
shellPGID = core.ShellPID
shellPGID = spec.ShellPID
}
var isCommandActive atomic.Bool
isExecuting := func() bool {
@@ -561,7 +561,7 @@ func runWrapper() {
results := MergeResults("", currentMode)
if len(results) > 0 {
limit := min(len(results), 100)
var historyList []core.Suggestion
var historyList []spec.Suggestion
if inputSlice[i+2] == 'A' {
for j := limit - 1; j >= 0; j-- {
@@ -888,7 +888,7 @@ func runWrapper() {
var target string
var ok bool
if isSpaceAlias {
target, ok = core.GetAlias(naiveBuffer)
target, ok = spec.GetAlias(naiveBuffer)
}
bufferMu.Unlock()