aboutsummaryrefslogtreecommitdiff
path: root/awwan.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-10-06 01:33:12 +0700
committerShulhan <ms@kilabit.info>2023-10-06 01:33:12 +0700
commitb22f2104dd822a890b8f8b8de5489215493c0812 (patch)
tree08b4c281c95ff7f8693cddc3dce2ce25c46c57cf /awwan.go
parent006fe79d7523c47102462595d8e8664fc1910c6a (diff)
downloadawwan-b22f2104dd822a890b8f8b8de5489215493c0812.tar.xz
all: simplify parsing statement for magic command get
This changes minimize code duplication when parsing magic command between "#get:" and "#get!" using single function parseStatementGetPut. In the returned Statement, we changes where to store the source argument into args[0] instead of in cmd for better readability and minimize confusion in Copy/SudoCopy. While at it, we add unit test for "#get:". Unit test for "#get!" is not possible right now, because it will prompt for password.
Diffstat (limited to 'awwan.go')
-rw-r--r--awwan.go9
1 files changed, 1 insertions, 8 deletions
diff --git a/awwan.go b/awwan.go
index bb38a8e..b7835f3 100644
--- a/awwan.go
+++ b/awwan.go
@@ -41,14 +41,7 @@ const defEncryptExt = `.vault`
// defFileEnvVault default awwan environment file name that is encrypted.
const defFileEnvVault = `.awwan.env.vault`
-var (
- cmdMagicGet = []byte("#get:")
- cmdMagicPut = []byte("#put:")
- cmdMagicSudoGet = []byte("#get!")
- cmdMagicSudoPut = []byte("#put!")
- cmdMagicRequire = []byte("#require:")
- newLine = []byte("\n")
-)
+var newLine = []byte("\n")
// Awwan is the service that run script in local or remote.
// Awwan contains cache of sessions and cache of environment files.