Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 99c7633

Browse files
committed
Version Bump: 0.5.0
Fix nick list loading issue Fix tab complete issue with \x00 Logo update
1 parent 76ad403 commit 99c7633

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2307
-241
lines changed

komanda/client/channel.go

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66

77
"github.com/fatih/color"
88
"github.com/jroimartin/gocui"
9+
10+
"github.com/hectane/go-nonblockingchan"
911
)
1012

1113
type RenderHandlerFunc func(*Channel, *gocui.View) error
@@ -33,6 +35,8 @@ type Channel struct {
3335
Topic string
3436
TopicSetBy string
3537
Users []*User
38+
NickListReady bool
39+
Loading *nbc.NonBlockingChan
3640
}
3741

3842
func (channel *Channel) View() (*gocui.View, error) {

komanda/client/server.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55

66
ircClient "github.com/fluffle/goirc/client"
7+
"github.com/hectane/go-nonblockingchan"
78
"github.com/jroimartin/gocui"
89
)
910

@@ -109,12 +110,14 @@ func (server *Server) NewChannel(name string, private bool) error {
109110
maxX, maxY := server.Gui.Size()
110111

111112
channel := Channel{
112-
Topic: "Loading...",
113-
Ready: false,
114-
Unread: private,
115-
Name: name,
116-
MaxX: maxX,
117-
MaxY: maxY,
113+
Topic: "Loading...",
114+
Ready: false,
115+
Unread: private,
116+
Name: name,
117+
MaxX: maxX,
118+
MaxY: maxY,
119+
Loading: nbc.New(),
120+
NickListReady: false,
118121
RenderHandler: func(channel *Channel, view *gocui.View) error {
119122
return nil
120123
},

komanda/command/clear.go

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func clearCmd() Command {
4242
return &ClearCmd{
4343
MetadataTmpl: &MetadataTmpl{
4444
name: "clear",
45+
args: "",
4546
aliases: []string{
4647
"cls",
4748
},

komanda/command/command.go

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var (
1010

1111
type MetadataTmpl struct {
1212
name string
13+
args string
1314
description string
1415
aliases []string
1516
}
@@ -18,6 +19,10 @@ func (c *MetadataTmpl) Name() string {
1819
return c.name
1920
}
2021

22+
func (c *MetadataTmpl) Args() string {
23+
return c.args
24+
}
25+
2126
func (c *MetadataTmpl) Description() string {
2227
return c.description
2328
}
@@ -28,6 +33,7 @@ func (c *MetadataTmpl) Aliases() []string {
2833

2934
type CommandMetadata interface {
3035
Name() string
36+
Args() string
3137
Description() string
3238
Aliases() []string
3339
}
@@ -56,6 +62,7 @@ func Register(server *client.Server) {
5662
topicCmd(),
5763
windowCmd(),
5864
namesCmd(),
65+
queryCmd(),
5966
}
6067
}
6168

komanda/command/connect.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ func (e *ConnectCmd) Exec(args []string) error {
4040
select {
4141
case <-ticker.C:
4242
fmt.Fprint(v, ".")
43-
case msg := <-ui.LoadingChannel:
43+
case msg := <-ui.LoadingChannel.Recv:
4444
if msg == "done" {
45+
4546
fmt.Fprint(v, "\n")
4647
ticker.Stop()
47-
close(ui.LoadingChannel)
4848
break
4949
}
5050
}
@@ -61,6 +61,7 @@ func connectCmd() Command {
6161
return &ConnectCmd{
6262
MetadataTmpl: &MetadataTmpl{
6363
name: "connect",
64+
args: "",
6465
aliases: []string{
6566
"c",
6667
},

komanda/command/empty.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func emptyCmd() Command {
2929
return &EmptyCmd{
3030
MetadataTmpl: &MetadataTmpl{
3131
name: "empty",
32+
args: "",
3233
description: "empty command",
3334
},
3435
}

komanda/command/exit.go

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func exitCmd() Command {
2525
return &ExitCmd{
2626
MetadataTmpl: &MetadataTmpl{
2727
name: "exit",
28+
args: "",
2829
aliases: []string{
2930
"q",
3031
"quit",

komanda/command/help.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func (e *HelpCmd) Exec(args []string) error {
2323

2424
for _, command := range Commands {
2525
metadata := command.Metadata()
26-
client.StatusMessage(v, fmt.Sprintf("/%s - %s",
27-
metadata.Name(), metadata.Description()))
26+
client.StatusMessage(v, fmt.Sprintf("/%s %s - %s",
27+
metadata.Name(), metadata.Args(), metadata.Description()))
2828
}
2929

3030
client.StatusMessage(v, "==================== HELP COMMANDS ====================\n")

komanda/command/join.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func joinCmd() Command {
3939
return &JoinCmd{
4040
MetadataTmpl: &MetadataTmpl{
4141
name: "join",
42+
args: "<channel>",
4243
aliases: []string{
4344
"j",
4445
},

komanda/command/logo.go

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func logoCmd() Command {
3232
return &LogoCmd{
3333
MetadataTmpl: &MetadataTmpl{
3434
name: "logo",
35+
args: "",
3536
description: "logo command",
3637
},
3738
}

komanda/command/names.go

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func namesCmd() Command {
3838
return &NamesCmd{
3939
MetadataTmpl: &MetadataTmpl{
4040
name: "names",
41+
args: "",
4142
aliases: []string{},
4243
description: "list channel names",
4344
},

komanda/command/nick.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func nickCmd() Command {
3939
return &NickCmd{
4040
MetadataTmpl: &MetadataTmpl{
4141
name: "nick",
42+
args: "<nick>",
4243
aliases: []string{
4344
"n",
4445
},

komanda/command/part.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ func partCmd() Command {
6868
return &PartCmd{
6969
MetadataTmpl: &MetadataTmpl{
7070
name: "part",
71+
args: "[channel]",
7172
aliases: []string{
7273
"p",
7374
},
74-
description: "part irc channel",
75+
description: "part irc channel or current if no channel given",
7576
},
7677
}
7778
}

komanda/command/pass.go

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func passCmd() Command {
3838
return &PassCmd{
3939
MetadataTmpl: &MetadataTmpl{
4040
name: "pass",
41+
args: "<password>",
4142
aliases: []string{
4243
"password",
4344
"server-password",

komanda/command/query.go

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package command
2+
3+
import (
4+
"strings"
5+
6+
"github.com/jroimartin/gocui"
7+
"github.com/mephux/komanda-cli/komanda/client"
8+
)
9+
10+
type QueryCmd struct {
11+
*MetadataTmpl
12+
}
13+
14+
func (e *QueryCmd) Metadata() CommandMetadata {
15+
return e
16+
}
17+
18+
func (e *QueryCmd) Exec(args []string) error {
19+
Server.Exec(client.StatusChannel, func(g *gocui.Gui, v *gocui.View, s *client.Server) error {
20+
21+
if !s.Client.Connected() {
22+
client.StatusMessage(v, "Not connected")
23+
return nil
24+
}
25+
26+
if len(args) >= 2 && len(args[1]) > 0 {
27+
CurrentChannel = args[1]
28+
s.CurrentChannel = args[1]
29+
30+
s.NewChannel(args[1], true)
31+
32+
if len(args[2]) > 0 {
33+
go Server.Client.Privmsg(args[1],
34+
strings.Replace(args[2], "\x00", "", -1))
35+
}
36+
37+
}
38+
39+
return nil
40+
})
41+
42+
return nil
43+
}
44+
45+
func queryCmd() Command {
46+
return &QueryCmd{
47+
MetadataTmpl: &MetadataTmpl{
48+
name: "query",
49+
args: "<user> [message]",
50+
aliases: []string{
51+
"pm",
52+
},
53+
description: "send private message to user",
54+
},
55+
}
56+
}

komanda/command/raw.go

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func rawCmd() Command {
3737
return &RawCmd{
3838
MetadataTmpl: &MetadataTmpl{
3939
name: "raw",
40+
args: "<command> [data]",
4041
description: "raw command",
4142
},
4243
}

komanda/command/status.go

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func statusCmd() Command {
3232
return &StatusCmd{
3333
MetadataTmpl: &MetadataTmpl{
3434
name: "status",
35+
args: "",
3536
description: "status command",
3637
},
3738
}

komanda/command/topic.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ func topicCmd() Command {
3939
return &TopicCmd{
4040
MetadataTmpl: &MetadataTmpl{
4141
name: "topic",
42+
args: "[channel] [topic]",
4243
aliases: []string{
4344
"t",
4445
},
45-
description: "set channel topic",
46+
description: "set topic for given channel or current channel if empty",
4647
},
4748
}
4849
}

komanda/command/version.go

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func versionCmd() Command {
2828
return &VersionCmd{
2929
MetadataTmpl: &MetadataTmpl{
3030
name: "version",
31+
args: "",
3132
aliases: []string{
3233
"v",
3334
},

komanda/command/window.go

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func windowCmd() Command {
5454
return &WindowCmd{
5555
MetadataTmpl: &MetadataTmpl{
5656
name: "window",
57+
args: "<id>",
5758
aliases: []string{
5859
"w",
5960
},

komanda/gui.go

+13-12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/mephux/komanda-cli/komanda/command"
1111
"github.com/mephux/komanda-cli/komanda/logger"
1212
"github.com/mephux/komanda-cli/komanda/ui"
13+
termbox "github.com/nsf/termbox-go"
1314
)
1415

1516
var Server *client.Server
@@ -92,19 +93,19 @@ func Run(build string, server *client.Server) {
9293
log.Panicln(err)
9394
}
9495

95-
// if err := g.SetKeybinding("input", gocui.KeyArrowLeft, gocui.Modifier(termbox.InputAlt),
96-
// func(g *gocui.Gui, v *gocui.View) error {
97-
// return prevView(g, v)
98-
// }); err != nil {
99-
// log.Panicln(err)
100-
// }
96+
if err := g.SetKeybinding("input", gocui.KeyArrowLeft, gocui.Modifier(termbox.InputAlt),
97+
func(g *gocui.Gui, v *gocui.View) error {
98+
return prevView(g, v)
99+
}); err != nil {
100+
log.Panicln(err)
101+
}
101102

102-
// if err := g.SetKeybinding("input", gocui.KeyArrowRight, gocui.Modifier(termbox.ModAlt),
103-
// func(g *gocui.Gui, v *gocui.View) error {
104-
// return nextView(g, v)
105-
// }); err != nil {
106-
// log.Panicln(err)
107-
// }
103+
if err := g.SetKeybinding("input", gocui.KeyArrowRight, gocui.Modifier(termbox.ModAlt),
104+
func(g *gocui.Gui, v *gocui.View) error {
105+
return nextView(g, v)
106+
}); err != nil {
107+
log.Panicln(err)
108+
}
108109

109110
if err := g.SetKeybinding("", gocui.KeyCtrlN,
110111
gocui.ModNone, nextView); err != nil {

0 commit comments

Comments
 (0)