aboutsummaryrefslogtreecommitdiff
path: root/statement.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-10-22 01:06:38 +0700
committerShulhan <ms@kilabit.info>2023-10-22 01:32:42 +0700
commitfc7cd444e7d637c291a3f9ba9987ba0335af4809 (patch)
treef1a32b5081417a1d64fe2cf88345ecf4494d3f97 /statement.go
parent4411ca1953c95ddc013e47c55e87303b7290e2cc (diff)
downloadawwan-fc7cd444e7d637c291a3f9ba9987ba0335af4809.tar.xz
all: add magic command "#local"
The magic command "#local" define the command to be executed using shell in local environment. Its have effect and can only be used in script that executed using "play". In script that is executed using "local" it does nothing.
Diffstat (limited to 'statement.go')
-rw-r--r--statement.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/statement.go b/statement.go
index ff59ca7..0468123 100644
--- a/statement.go
+++ b/statement.go
@@ -17,6 +17,7 @@ import (
const (
statementKindDefault int = iota
statementKindComment
+ statementKindLocal
statementKindRequire
statementKindGet
statementKindPut
@@ -27,6 +28,7 @@ const (
// List of magic command.
var (
cmdMagicGet = []byte(`#get:`)
+ cmdMagicLocal = []byte(`#local:`)
cmdMagicPut = []byte(`#put:`)
cmdMagicSudoGet = []byte(`#get!`)
cmdMagicSudoPut = []byte(`#put!`)
@@ -85,6 +87,18 @@ func ParseStatement(raw []byte) (stmt *Statement, err error) {
args []string
)
+ if bytes.HasPrefix(raw, cmdMagicLocal) {
+ raw = raw[len(cmdMagicLocal):]
+ cmd, args = libexec.ParseCommandArgs(string(raw))
+ stmt = &Statement{
+ kind: statementKindLocal,
+ cmd: cmd,
+ args: args,
+ raw: raw,
+ }
+ return stmt, nil
+ }
+
if bytes.HasPrefix(raw, cmdMagicRequire) {
raw = raw[len(cmdMagicRequire):]
cmd, args = libexec.ParseCommandArgs(string(raw))