forked from cwtch.im/cwtch
Merge branch 'export-group' of dan/cwtch into master
This commit is contained in:
commit
8764417b0e
|
@ -29,6 +29,7 @@ var suggestions = []prompt.Suggest{
|
|||
{Text: "peers", Description: "retrieve a list of peers and their connection status"},
|
||||
{Text: "contacts", Description: "retrieve a list of contacts"},
|
||||
{Text: "groups", Description: "retrieve a list of groups"},
|
||||
{Text: "export-group", Description: "export a group invite: prints as a string"},
|
||||
{Text: "send", Description: "send a message to a group"},
|
||||
{Text: "timeline", Description: "read the timeline of a given group"},
|
||||
{Text: "accept-invite", Description: "accept the invite of a group"},
|
||||
|
@ -48,6 +49,7 @@ var usages = map[string]string{
|
|||
"peers": "",
|
||||
"contacts": "",
|
||||
"groups": "",
|
||||
"export-group": "export-group [groupid]",
|
||||
"info": "",
|
||||
"send": "send [groupid] [message]",
|
||||
"timeline": "timeline [groupid]",
|
||||
|
@ -64,12 +66,16 @@ func completer(d prompt.Document) []prompt.Suggest {
|
|||
|
||||
var s []prompt.Suggest
|
||||
|
||||
if app.Peer == nil {
|
||||
return s
|
||||
}
|
||||
|
||||
if d.FindStartOfPreviousWord() == 0 {
|
||||
return prompt.FilterHasPrefix(suggestions, d.GetWordBeforeCursor(), true)
|
||||
}
|
||||
|
||||
w := d.CurrentLine()
|
||||
if strings.HasPrefix(w, "send") || strings.HasPrefix(w, "timeline") {
|
||||
if strings.HasPrefix(w, "send") || strings.HasPrefix(w, "timeline") || strings.HasPrefix(w, "export-group") {
|
||||
s = []prompt.Suggest{}
|
||||
groups := app.Peer.GetGroups()
|
||||
for _, groupID := range groups {
|
||||
|
@ -390,7 +396,7 @@ func main() {
|
|||
fmt.Printf("Invite: %v\n", invite)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("Error reading timeline from group, usage: %s\n", usages["timeline"])
|
||||
fmt.Printf("Error exporting group, usage: %s\n", usages["export-group"])
|
||||
}
|
||||
case "save":
|
||||
app.Peer.Save()
|
||||
|
|
Loading…
Reference in New Issue