UNPKG

862 BJavaScriptView Raw
1var u = require('./util')
2
3exports.help = `
4Usage: git ssb name [<repo>] <name>
5
6 Publish a name for a git-ssb repo
7
8Arguments:
9 repo id, url, or git remote name of the base repo.
10 default: 'origin' or 'ssb'
11 name the name to give the repo
12`
13
14exports.fn = function (argv) {
15 if (argv._.length < 1 || argv._.length > 2) return u.help('name')
16
17 var repo
18 if (argv._.length == 1) repo = u.getRemote()
19 else if (argv._.length == 2) repo = u.getRemote(argv._.shift())
20 if (!repo) throw 'unable to find git-ssb repo'
21 var name = argv._[0]
22 if (!name) throw 'missing name'
23
24 u.getSbot(argv, function (err, sbot) {
25 if (err) throw err
26 var schemas = require('ssb-msg-schemas')
27 sbot.publish(schemas.name(repo, name), function (err, msg) {
28 if (err) throw err
29 console.log(msg.key)
30 sbot.close()
31 })
32 })
33}
34