-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnscript.d.ts
115 lines (96 loc) · 3.01 KB
/
nscript.d.ts
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
interface Shell {
pid: number;
env: {[key:string]:string};
colors:any; // See node module colors
glob(pattern:string,opts?:Object):string[];
lastExitCode: number;
future:any; // See node-fibers module
nscript(nscriptFunction:NscriptFunction, callback:(err:any,returnValue:any)=>void);
alias(...args:CommandArg[]):Command;
cmd(...args:CommandArg[]):Command;
exit(status?:number, message?:string);
prompt(promt:string, defaultValue?:string):string;
verbose(verboseMode:boolean);
useGlobal();
cwd():string;
pwd():string;
cd(newPath?:string);
pushd(newPath: string);
popd();
isFile(filename:string):boolean;
isDir(path:string):boolean;
files(path:string):string[];
write(filename:string, text:string);
append(filename:string, text:string);
read(filename:string):string;
/* Wrappers of command */
run(...args:CommandArg[]):number;
code(...args:CommandArg[]):number;
test(...args:CommandArg[]):boolean;
get(...args:CommandArg[]):string;
getError(...args:CommandArg[]):string;
getLines(...args:CommandArg[]):string[];
detach(...args:CommandArg[]):number;
spawn(...args:CommandArg[]):SpawnedCommand;
}
interface Command {
options(optionsOfNewCommand:CommandOptions):Command;
args(...args:CommandArg[]):Command;
argsSplat(args:CommandArg[]):Command;
silent():Command;
relax():Command;
env(key:string,value:string):Command;
env(envVariables:{[key:string]:string;}):Command;
spawn():SpawnedCommand;
/* Wrappers of SpawnedCommand */
(...args:CommandArg[]):number;
run(...args:CommandArg[]):number;
code(...args:CommandArg[]):number;
test(...args:CommandArg[]):boolean;
get(...args:CommandArg[]):string;
getError(...args:CommandArg[]):string;
getLines(...args:CommandArg[]):string[];
input(fd:number):Command;
input(readable:{pipe:Function;}):Command;
input(data:string):Command;
read(filename:string):Command;
pipe(cmd:Command|string, ...args:CommandArg[]):Command;
write(filename:string):number;
append(filename:string):number;
detach(...args:CommandArg[]):number;
writeError(filename:string):SpawnedCommand;
appendError(filename:string):SpawnedCommand;
}
interface CommandOptions {
silent?:boolean;
}
interface SpawnedCommand {
pid: number;
process: any;
get():string;
getError():string;
getLines():string[];
pipe(cmd:Command|string, ...args:CommandArg[]):SpawnedCommand;
write(filename:string):SpawnedCommand;
append(filename:string):SpawnedCommand;
writeError(filename:string):SpawnedCommand;
appendError(filename:string):SpawnedCommand;
wait():number;
test():boolean;
code():number;
onClose(cb:(status:number)=>void):SpawnedCommand;
onOut(cb:(line:string)=>void):SpawnedCommand;
onError(cb:(line:string)=>void):SpawnedCommand;
}
interface NscriptFunction {
(shell:Shell, ...injectedArgs:NscriptArg[]):any;
}
declare type CommandArg = string | {[flag:string]:string|boolean} | string[];
declare type NscriptArg = string | boolean | Command;
declare function nscript(
nscriptFunction:NscriptFunction,
callback?:(error:any,returnValue:any)=>void
);
declare module "nscript" {
export = nscript;
}