-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathom.woo
More file actions
177 lines (149 loc) · 5.63 KB
/
om.woo
File metadata and controls
177 lines (149 loc) · 5.63 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!woo
-- Author: liyanxi
-- Email: liyanxi_rhett@outlook.com
-- when install this plugs ,the init.woo will be run one times.
--https://gitee.com/oshine/om/raw/master/init.woo
--curl https://gitee.com/oshine/om/raw/master/init.woo -s
--print('dir:==', dir(''))
--print(_DIR)
--print('pwd:==', pwd())
local table = table
install_dir = _env('OM_PATH') or _home() .. '/om'
package.path = install_dir .. '/?.woo;' .. package.path .. ';'
local conf = require('oshine.om@:conf.conf')
local trs = require('oshine.om@:conf.trs')
local lan = conf.language
print("package.path:===", package.path)
local args1 = _args()
table.remove(args1, 1)
if _os() == 'windows' then
if args1[1] == 'om' then
table.remove(args1, 1)
end
else
-- handler for cmdline [om cmd oshine/rename rename]
if #args1 > 2 then
local r = require(args1[2] .. '.cmd.' .. args1[3])
local p = {}
if #args1 > 3 then
local index = 1
for i, v in pairs(args1) do
if index > 3 then
p[i] = v
end
index = index + 1
end
end
r.run(p)
end
return
end
print('om get real args:===', _json_encode(args1))
if _in_array(args1[1], { 'install', 'i' }) then
require('oshine.om@1.?:installer'):new(args1[2] or _pwd()):install()
return
end
local any_type = require('oshine.woo_any_type@:anyType'):new(args1)
local capture = require('oshine.woo_args@:capture'):new(any_type:sliceToRight(1))
any_type = nil
capture:catch('login', function(login_c)
print('login ready>>>')
local member = require('oshine.om@1.?:api.member'):new()
local email = login_c:catchNext()
member:login(email)
end) :catch('logout', function()
print('logout ...')
require('oshine.om@1.?:api.member'):new():logout()
end) :catch({ 'i', 'install' }, function(c)
c:catch('plugs', function()
-- install self , just copy self folder to om package folder make sure you can load the lib anywhere
-- install dir is [~/username/om/]
require('oshine.om@:installer'):new(args1[3] or _pwd()):install_plugs()
end)
end) :catch('send', function(c, is_show_help)
if is_show_help then
return [[om send his]]
end
-- om send oshine ./pac.zip [bg:]
-- 发送文件给好友
c :catch('user', function(user_c)
local user = user_c:catchNext() --or user_c:catchArg({ 'u:', '--user' })
local files = user_c:catchNextAll() --or user_c:catchArg({ 'f:', '--file' })
require('oshine.om@1.?:cloud'):new():send(user, files)
end):catch({ 'his', 'history' }, function()
end):catch({ 'list', 'ls' }, function()
end):catch({ 'que', 'queue' }, function()
end):run()
end) :catch({ 'pro', 'program' }, function()
end) :catch({ 'conf', 'config' }, function()
end) :catch({ 'storage' }, function()
-- local storage/本地存储命令行
end) :catch({ 'article', 'art' }, function()
end) :catch({ 'fav', 'favorite' }, function()
end) :catch({ 'clo', 'cloud' }, function()
-- cloud storage/云存储,oss|disk
end) :catch('hook', function()
-- toggle hook,can be all resources hook,like article,file,picture,video,audio... [触发钩子,各种资源钩子,文章/文件/图片/视频/音频/...:
-- om hook oshine/177821
end) :catch('api', function()
-- om api storage exchange 100GB
end) :catch('check', function()
-- check all installed plug's status/检查所有的已经安装的plugs的运行状态
end) :catch('status', function(c)
--c:trgger('pakcage.status')
end) :catch('package', function(package_c, is_show_help)
if is_show_help then
return trs[lan]['']
end
local action = package_c:catchNext()
if action == 'search:l' or action == 'search' then
-- exec local cmd line
local pac = require('oshine.om@1.?:local_parse.package'):new()
action = package_c:catchNext()
if action == 'search' then
pac:search()
elseif action == 'list' then
pac:status()
end
return
end
local pac = require('oshine.om@1.?:api.package'):new()
if action == 'push' then
local package_name = package_c:catchNext()
local git_source = package_c:catchNext()
pac:add(package_name, git_source)
elseif action == 'search:g' then
local key = package_c:catchNext()
pac:search(key)
elseif action == 'new' then
-- 在当前目录新建一个package,如果存在package.woo文件,那么退出
elseif action == 'list' then
pac:status()
end
end) :catch('test', function()
-- om test oshine/bitmap [main] // show all demo about oshine/bitmap
-- om test oshine/bitmap circle // run circle demo
-- om test oshine/bitmap list: // run circle demo
end) :catch('config', function(package_c, is_show_help)
local key = package_c:catchNext()
local val = package_c:catchNext()
if key and val then
require('oshine.om@1.?:utils.utils').configSet(key, val, function()
conf = require('oshine.om@:conf.conf')
end)
elseif is_show_help then
end
end) :catch('search', function()
-- search a:article ,share hook...
-- search f:php ,share hook...
end) :catch({ 'u', 'update' }, function(c)
local up_status = c:catchNext()
--om install rename
--om update -- 更新所有,有缓存使用缓存更新
--om update force -- 更新所有,强制升级
--om update rename force -- 更新rename,强制升级
--om update rename v: 1.2? -- 更新rename,强制升级
if up_status == 'f:' then
-- 强制升级,不使用缓存
end
end) :run()