feature: extra args for fileindir (#291)

This commit is contained in:
James Read 2024-04-26 00:32:58 +01:00 committed by GitHub
parent 318d4fe0d0
commit 12cf0013e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -16,6 +16,7 @@ var (
typecheckRegex = map[string]string{ typecheckRegex = map[string]string{
"very_dangerous_raw_string": "", "very_dangerous_raw_string": "",
"int": "^[\\d]+$", "int": "^[\\d]+$",
"unicode_identifier": "^[\\w\\/\\\\.\\_ \\d]+$",
"ascii": "^[a-zA-Z0-9]+$", "ascii": "^[a-zA-Z0-9]+$",
"ascii_identifier": "^[a-zA-Z0-9\\-\\.\\_]+$", "ascii_identifier": "^[a-zA-Z0-9\\-\\.\\_]+$",
"ascii_sentence": "^[a-zA-Z0-9 \\,\\.]+$", "ascii_sentence": "^[a-zA-Z0-9 \\,\\.]+$",

View File

@ -5,6 +5,7 @@ import (
"github.com/OliveTin/OliveTin/internal/config" "github.com/OliveTin/OliveTin/internal/config"
"github.com/OliveTin/OliveTin/internal/executor" "github.com/OliveTin/OliveTin/internal/executor"
"github.com/OliveTin/OliveTin/internal/filehelper" "github.com/OliveTin/OliveTin/internal/filehelper"
"path/filepath"
) )
func WatchFilesInDirectory(cfg *config.Config, ex *executor.Executor) { func WatchFilesInDirectory(cfg *config.Config, ex *executor.Executor) {
@ -23,13 +24,17 @@ func WatchFilesInDirectory(cfg *config.Config, ex *executor.Executor) {
} }
} }
func scheduleExec(action *config.Action, cfg *config.Config, ex *executor.Executor, filename string) { func scheduleExec(action *config.Action, cfg *config.Config, ex *executor.Executor, path string) {
req := &executor.ExecutionRequest{ req := &executor.ExecutionRequest{
ActionTitle: action.Title, ActionTitle: action.Title,
Cfg: cfg, Cfg: cfg,
Tags: []string{"fileindir"}, Tags: []string{"fileindir"},
Arguments: map[string]string{ Arguments: map[string]string{
"filename": filename, "filepath": filepath.Base(path),
"filename": filepath.Base(path),
"filedir": filepath.Dir(path),
"fileext": filepath.Ext(path),
}, },
AuthenticatedUser: &acl.AuthenticatedUser{ AuthenticatedUser: &acl.AuthenticatedUser{
Username: "fileindir", Username: "fileindir",