-
Notifications
You must be signed in to change notification settings - Fork 75
/
help.js
142 lines (127 loc) · 3.08 KB
/
help.js
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
function rangeArg (desc, type) {
return {
type: type,
description: 'only results ' + desc + ' ' + type,
optional: true
}
}
function rangeArgs (type) {
return {
gte: rangeArg('greater than or equal to', type),
lte: rangeArg('less than or equal to', type),
gt: rangeArg('greater than ', type),
lt: rangeArg('less than', type),
reverse: {type: 'boolean', test: 'boolean', description: 'output is reversed', optional: true},
live: {type: 'boolean', test: 'boolean', description: 'include live results', optional: true},
old: {type: 'boolean', test: 'boolean', description: 'include old results', optional: true}
}
}
var keysAndValues = {
keys: {
type: 'boolean',
description: 'include keys',
optional: true
},
values: {
type: 'boolean',
description: 'include values',
optional: true
}
}
var MessageId = {
type: 'string',
test: /^%[a-zA-Z0-9+/]+={0,2}\.\w+$/
}
var Private = {
type: 'boolean',
description: 'decrypt private messages',
default: false
}
module.exports = {
description: 'append only-log database for secure-scuttlebutt',
commands: {
createLogStream: {
type: "source",
description: 'stream of all locally stored messages, in order received',
args:
Object.assign(rangeArgs('timestamp'), keysAndValues)
},
get: {
type: "async",
description: 'retrive a locally stored message',
args: {
id: MessageId,
private: Private,
meta: {
type: 'boolean',
description: 'include key, value, and timestamp',
default: false
}
}
},
publish: {
type: 'async',
description: 'publish a message',
args: {}
},
add: {
type: 'async',
description: 'append a valid message',
args: {},
},
status: {
type: 'sync',
description: 'show internal system statuses',
args: {}
},
progress: {
type: 'sync',
description: 'show internal progress',
args: {}
},
version: {
type: 'sync',
description: 'show version numbers',
args: {}
},
whoami: {
type: 'sync',
description: 'print main identity',
args: {}
},
createHistoryStream: {
type: 'source',
description: 'output messages from a feed in order',
args: Object.assign({
id: {
type: 'FeedId',
optional: false,
description: 'a ssb feed identity',
},
seq: {
type: 'SequenceNumber',
optional: true,
description: 'sequence number to stream from',
},
limit: {
type: 'number',
description: 'max number of messages to output',
optional: true
}
}, keysAndValues)
}
}
}
//ways to call usage:
//quick: lists commands, or help
//deep: print all options or all subcommands
//help: print all subcommands
/*
quick: command1|command2|command3...
deep: command1.foo
--blah <type> # description
...
help:
command1.foo --{blah,...}
command1.bar --{blah,...}
*/