-
Notifications
You must be signed in to change notification settings - Fork 6
/
sol
executable file
·145 lines (140 loc) · 4.87 KB
/
sol
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env node
const {program} = require('commander');
const sol = require('./src/sol.run.js'); // the commands
const shell = require('./src/sol.shell.js'); // the prompts
const {packageVersions} = require('./src/utils.js'); // version display
/*
* This file is the command-line interface
*/
async function main() {
await packageVersions(['../','solid-file-client','solid-node-client','@solid-rest/file']);
program.parse(process.argv);
}
program.option('-l,--login',"login");
program
.command('put <URL> [CONTENT...]')
.description('create a file or folder')
.action( async (URL,CONTENT) => {
if( program.opts().login ) await sol.runSol("login")
CONTENT = CONTENT.join(" ");
sol.runSol("put",[URL,CONTENT]).then(()=>{
},err=>console.log(err));
});
program
.command('post <URL> [CONTENT...]')
.description('create a file or folder')
.action( async (URL,CONTENT) => {
if( program.opts().login ) await sol.runSol("login")
CONTENT = CONTENT.join(" ");
sol.runSol("post",[URL,CONTENT]).then(()=>{
},err=>console.log(err));
});
program
.command('patch <URL> [CONTENT...]')
.description('create a file or folder')
.action( async (URL,CONTENT) => {
if( program.opts().login ) await sol.runSol("login")
CONTENT = CONTENT.join(" ");
sol.runSol("patch",[URL,CONTENT]).then(()=>{
},err=>console.log(err));
});
program
.command('options <URL>')
.description('create a file or folder')
.action( async (URL,CONTENT) => {
if( program.opts().login ) await sol.runSol("login")
CONTENT = CONTENT.join(" ");
sol.runSol("options").then(()=>{
},err=>console.log(err));
});
program
.command('head <URL>')
.description('show headers for a file or folder')
.action( async (URL) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("head",[URL]).then(()=>{
},err=>console.log(err));
});
program
.command('get <URL>')
.description('show contents of a file or folder')
.action( async (URL) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("get",[URL]).then(()=>{
},err=>console.log(err));
});
program
.command('copy <oldURL> <newURL> [noAux]')
.description('copy a file or recursively copy a folder')
.action( async (oldURL,newURL,noAux) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("copy",[oldURL,newURL,noAux]).then(()=>{
},err=>console.log(err));
});
program
.command('move <oldURL> <newURL>')
.description('move a file or recursively move a folder')
.action( async (oldURL,newURL) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("mv",[oldURL,newURL]).then(()=>{
},err=>console.log(err));
});
program
.command('delete <URL>')
.description('delete a file or an empty folder')
.action( async (URL) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("delete",[URL]).then(()=>{
},err=>console.log(err));
});
program
.command('recursiveDelete <URL>')
.description('recursively delete a folder tree')
.action( async (URL) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("delete",[URL]).then(()=>{
},err=>console.log(err));
});
program
.command('emptyFolder <URL>')
.description('recursively delete the contents of a folder tree')
.action( async (URL) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("emptyFolder",[URL]).then(()=>{
},err=>console.log(err));
});
program
.command('zip <folderURL> <zipFileURL>')
.description('create a zip archive')
.action( async (folderURL,zipFileURL) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("zip",[folderURL,zipFileURL]).then(()=>{
},err=>console.log(err));
});
program
.command('unzip <zipFileURL> <folderURL>')
.description('extract a zip archive')
.action( async (zipFileURL,folderURL) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("unzip",[zipFileURL,folderURL]).then(()=>{
},err=>console.log(err));
});
program
.command('run <scriptFile>')
.description('batch run commands in a script file')
.action( async (scriptFile) => {
if( program.opts().login ) await sol.runSol("login")
sol.runSol("run",[scriptFile]).then(()=>{
},err=>console.log(err) )
},err=>console.log(err));
program
.command('shell')
.description('run as an interactive shell')
.action( async () => {
console.clear();
if( program.opts().login ) await sol.runSol("login")
sol.runSol("help").then(()=>{
shell.sh()
},err=>console.log(err));
});
main();