-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Process.txt
99 lines (78 loc) · 3.38 KB
/
Process.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
*Vital.Async.Promise.Process.txt* System.Job wrapper with Promise
Author: Alisue <lambdalisue@hashnote.net>
=============================================================================
CONTENTS *Vital.Async.Promise.Process-contents*
Introduction |Vital.Async.Promise.Process-introduction|
Usage |Vital.Async.Promise.Process-usage|
Functions |Vital.Async.Promise.Process-functions|
=============================================================================
INTRODUCTION *Vital.Async.Promise.Process-introduction*
*Vital.Async.Promise.Process* is a module to provide a way to execute an
external program with a |Vital.Async.Promise| interface.
It internally uses |Vital.System.Job| to execute a program so it works both
on Vim and Neovim.
Note that if intermediate data is necessary, see
|Vital.Async.Observable.Process| instead.
=============================================================================
USAGE *Vital.Async.Promise.Process-usage*
Start an external program with |Vital.Async.Promise.Process.start()| function
by appling command arguments like:
>
call Process.start(['echo', 'Hello'])
\.then({ v -> execute('echo v', '') })
"{
" 'args': ['echo', 'Hello'],
" 'stdout': ['Hello', ''],
" 'stderr': [''],
" 'exitval': 0,
"}
<
=============================================================================
FUNCTIONS *Vital.Async.Promise.Process-functions*
.start({args}[, {options}]) *Vital.Async.Promise.Process.start()*
Execute a command {args} and return a Promise instance which will
be resolved when the process is terminated. Note that even the process
has terminated with non 0 exit-status, the promise is resolved rather
than rejected unless "reject_on_failure" option has specified. The
promise is rejected only when the process could not be started (e.g.
the given executable is not found).
The following attributes are available in {options}.
"cwd" Force to execute a process in a given
directory. Otherwise the process is executed
under a current directory.
"raw" TRUE to use raw data instead of \r removed
data.
"stdin" A Promise instance which resolve string or
string list to send messages into the process.
When this promise has resolved, the stdin
channel will be closed.
Note that rejection value is not used.
"token" An instance of |Vital.Async.CancellationToken|
to cancel process execution.
"reject_on_failure" Reject when the process exit with failure exit
status (non 0 exit status.) instead.
"abort" A Promise instance which is used to abort the
process.
Note that rejection value is not used.
WARNING deprecated.
The promise instance will be resolved with an object which has the
following attributes.
"args" Given arguments
"stdout" Stdout of the process in newline separated list.
"stderr" Stderr of the process in newline separated list.
"exitval" Exit value of the process
is_available() *Vital.Async.Promise.Process.is_available()*
Returns TRUE when requirements for using
|Vital.Async.Promise.Process| are met.
Requirements is that |Vital.Async.Promise| and |Vital.System.Job|
work.
Otherwise, returns FALSE.
>
if Process.is_available()
" Asynchronous operations using Process Promise
else
" Fallback into synchronous operations
endif
<
=============================================================================
vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl