-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcli
More file actions
executable file
·99 lines (94 loc) · 2.61 KB
/
cli
File metadata and controls
executable file
·99 lines (94 loc) · 2.61 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
#!/usr/bin/env node
const Twetch = require('./dist/twetch.node.min.js');
const twetch = new Twetch({ filePath: `${__dirname}/.bit` });
require('yargs')
.scriptName('twetch')
.command('init', 'to get started run this', {}, async argv => {
twetch.init();
})
.command('address', 'display your wallet signing address', {}, async argv => {
const address = await twetch.wallet.address();
console.log('address: ', address);
process.exit();
})
.command('backup', 'backup your wallet', {}, () => {
twetch.wallet.backup();
})
.command('balance', 'fetch your wallet balance', {}, async argv => {
const balance = await twetch.wallet.balance();
console.log('balance: ', balance / 100000000, 'BSV');
process.exit();
})
.command(
'like',
'like a twetch post',
yargs =>
yargs.option('t', {
alias: 'transaction',
describe: 'txid of the post to like'
}),
async argv => {
const payload = {
postTransaction: argv.transaction
};
const response = await twetch.publish('twetch/like@0.0.1', payload);
if (response.published) {
console.log(`liked! https://twetch.app/t/${argv.transaction}`);
}
}
)
.command(
'post',
'publish a message on Twetch',
yargs =>
yargs
.option('f', {
alias: 'file',
describe: 'path of file you want posted to twetch'
})
.option('c', {
alias: 'content',
describe: 'content you want posted to twetch'
})
.option('r', {
alias: 'reply',
describe: 'txid of post to reply to'
})
.option('t', {
alias: 'tweet',
describe: 'tweet from twetch'
})
.option('h', {
alias: 'hide',
describe: 'hide tweet from twetch link'
}),
async argv => {
const payload = {
bContent: argv.file ? undefined : argv.content,
payParams: { tweetFromTwetch: argv.tweet || false, hideTweetFromTwetchLink: argv.hide || false },
mapComment: (argv.file && argv.content ? argv.content : '') || '',
mapReply: argv.reply || 'null'
};
const response = await twetch.publish('twetch/post@0.0.1', payload, argv.file);
if (response.published) {
console.log(`published! https://twetch.app/t/${response.txid}`);
}
process.exit();
}
)
.command(
'restore',
'restore your wallet',
yargs => yargs.option('k', { alias: 'key', describe: 'private key WIF' }),
argv => {
if (!argv.key) {
return console.log('you must specify a private key');
}
twetch.wallet.restore(argv.key);
console.log('Wallet restored from private key');
}
)
.command('storage', 'get information about persistant storage', {}, () => {
console.log('path', twetch.storage.filePath);
})
.help().argv;