diff options
| author | Shulhan <ms@kilabit.info> | 2023-03-20 00:28:14 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-03-20 13:53:53 +0700 |
| commit | b7fc0aad9f394c99b9cfd258db6abb4ecee028a9 (patch) | |
| tree | f6ab2efa3015be0e9bd92b8a2c7b8eaf2ff4375a /request.go | |
| parent | 42e96adf2ea2bab6f173bd38eed49f30346867dd (diff) | |
| download | awwan-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 'request.go')
| -rw-r--r-- | request.go | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -20,18 +20,27 @@ type Request struct { scriptPath string // The actual or cleaned up path of the Script. script *Script - Mode string `json:"mode"` - Script string `json:"script"` - Content []byte `json:"content"` - BeginAt int `json:"begin_at"` - EndAt int `json:"end_at"` + Mode string `json:"mode"` + Script string `json:"script"` + LineRange string `json:"line_range"` + Content []byte `json:"content"` + + lineRange lineRange } // NewRequest create new Request and initialize stdout and stderr to os.Stdout // and os.Stderr. -func NewRequest() *Request { - return &Request{ +func NewRequest(mode, script, lineRange string) (req *Request) { + req = &Request{ stdout: os.Stdout, stderr: os.Stderr, + + Mode: mode, + Script: script, + LineRange: lineRange, } + + req.lineRange = parseLineRange(lineRange) + + return req } |
