2
2
ミラー元 https://github.com/Hilbis/Hilbish 前回の同期 2025-07-10 21:12:02 +00:00

chore: merge from upstream

このコミットが含まれているのは:
sammyette 2023-09-09 13:53:22 -04:00
コミット 4fcd310048
署名者: sammyette
GPGキーID: 904FC49417B44DCD
3個のファイルの変更28行の追加1行の削除

ファイルの表示

@ -12,6 +12,9 @@
- `hilbish.notification` signal when a message/notification is sent - `hilbish.notification` signal when a message/notification is sent
- `notifyJobFinish` opt to send a notification when background jobs are - `notifyJobFinish` opt to send a notification when background jobs are
completed. completed.
- Allow numbered arg substitutions in aliases.
- Example: `hilbish.alias('hello', 'echo %1 says hello')` allows the user to run `hello hilbish`
which will output `hilbish says hello`.
[#219]: https://github.com/Rosettea/Hilbish/issues/219 [#219]: https://github.com/Rosettea/Hilbish/issues/219
### Fixed ### Fixed

ファイルの表示

@ -1,6 +1,8 @@
package main package main
import ( import (
"regexp"
"strconv"
"strings" "strings"
"sync" "sync"
@ -46,9 +48,27 @@ func (a *aliasModule) Resolve(cmdstr string) string {
a.mu.RLock() a.mu.RLock()
defer a.mu.RUnlock() defer a.mu.RUnlock()
args := strings.Split(cmdstr, " ") arg, _ := regexp.Compile(`[\\]?%\d+`)
args, _ := splitInput(cmdstr)
for a.aliases[args[0]] != "" { for a.aliases[args[0]] != "" {
alias := a.aliases[args[0]] alias := a.aliases[args[0]]
alias = arg.ReplaceAllStringFunc(alias, func(a string) string {
idx, _ := strconv.Atoi(a[1:])
if strings.HasPrefix(a, "\\") || idx == 0 {
return strings.TrimPrefix(a, "\\")
}
if idx + 1 > len(args) {
return a
}
val := args[idx]
args = cut(args, idx)
cmdstr = strings.Join(args, " ")
return val
})
cmdstr = alias + strings.TrimPrefix(cmdstr, args[0]) cmdstr = alias + strings.TrimPrefix(cmdstr, args[0])
cmdArgs, _ := splitInput(cmdstr) cmdArgs, _ := splitInput(cmdstr)
args = cmdArgs args = cmdArgs

ファイルの表示

@ -324,3 +324,7 @@ func getVersion() string {
return v.String() return v.String()
} }
func cut(slice []string, idx int) []string {
return append(slice[:idx], slice[idx + 1:]...)
}