aboutsummaryrefslogtreecommitdiff
path: root/http_api.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-03-20 00:28:14 +0700
committerShulhan <ms@kilabit.info>2023-03-20 13:53:53 +0700
commitb7fc0aad9f394c99b9cfd258db6abb4ecee028a9 (patch)
treef6ab2efa3015be0e9bd92b8a2c7b8eaf2ff4375a /http_api.go
parent42e96adf2ea2bab6f173bd38eed49f30346867dd (diff)
downloadawwan-b7fc0aad9f394c99b9cfd258db6abb4ecee028a9.tar.xz
all: changes the line number arguments for "local" and "play" command
Previously, the "local" and "play" command only accept two kind of arguments: one argument for executing single line or two arguments for executing line range. There are no options to executing multiple single line, multiple line range, or combination of them. This changes make the both commands accept list of lines or line range where each separated by comma. For example, to execute multiple, different single lines awwan local 4,8,12 To execute multiple line range, awwan local 4-8,12-16 Or to execute multiple lines and line range, awwan local 4,8,10-12
Diffstat (limited to 'http_api.go')
-rw-r--r--http_api.go11
1 files changed, 2 insertions, 9 deletions
diff --git a/http_api.go b/http_api.go
index a0b3163..c5d1c56 100644
--- a/http_api.go
+++ b/http_api.go
@@ -6,7 +6,6 @@ package awwan
import (
"encoding/json"
"fmt"
- "math"
"net/http"
"os"
"path"
@@ -327,7 +326,7 @@ func (aww *Awwan) httpApiFsPut(epr *libhttp.EndpointRequest) (rawBody []byte, er
func (aww *Awwan) httpApiExecute(epr *libhttp.EndpointRequest) (resb []byte, err error) {
var (
logp = "httpApiExecute"
- req = NewRequest()
+ req = &Request{}
res = &libhttp.EndpointResponse{}
data *HttpResponse
@@ -342,13 +341,7 @@ func (aww *Awwan) httpApiExecute(epr *libhttp.EndpointRequest) (resb []byte, err
}
req.Script = filepath.Join(aww.memfsBase.Opts.Root, req.Script)
- if req.BeginAt == 0 && req.EndAt == 0 {
- req.BeginAt = 1
- req.EndAt = math.MaxInt
- }
- if req.EndAt < req.BeginAt {
- req.EndAt = req.BeginAt
- }
+ req.lineRange = parseLineRange(req.LineRange)
aww.bufout.Reset()
aww.buferr.Reset()