mirror of
https://github.com/Rudi9719/kbtui.git
synced 2026-03-22 11:07:22 +00:00
Cleanup
This commit is contained in:
@ -5,8 +5,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/jroimartin/gocui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -20,7 +18,7 @@ func init() {
|
|||||||
RegisterCommand(command)
|
RegisterCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdHelp(g *gocui.Gui, cmd []string) {
|
func cmdHelp(cmd []string) {
|
||||||
var helpText string
|
var helpText string
|
||||||
if len(cmd) == 1 {
|
if len(cmd) == 1 {
|
||||||
sort.Strings(baseCommands)
|
sort.Strings(baseCommands)
|
||||||
|
|||||||
@ -5,7 +5,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jroimartin/gocui"
|
|
||||||
"samhofi.us/x/keybase"
|
"samhofi.us/x/keybase"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ func init() {
|
|||||||
RegisterCommand(command)
|
RegisterCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdJoin(g *gocui.Gui, cmd []string) {
|
func cmdJoin(cmd []string) {
|
||||||
stream = false
|
stream = false
|
||||||
if len(cmd) == 3 {
|
if len(cmd) == 3 {
|
||||||
channel.MembersType = keybase.TEAM
|
channel.MembersType = keybase.TEAM
|
||||||
|
|||||||
@ -4,8 +4,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jroimartin/gocui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -19,7 +17,7 @@ func init() {
|
|||||||
RegisterCommand(command)
|
RegisterCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdUploadFile(g *gocui.Gui, cmd []string) {
|
func cmdUploadFile(cmd []string) {
|
||||||
filePath := cmd[1]
|
filePath := cmd[1]
|
||||||
var fileName string
|
var fileName string
|
||||||
if len(cmd) == 3 {
|
if len(cmd) == 3 {
|
||||||
|
|||||||
4
main.go
4
main.go
@ -352,7 +352,7 @@ func handleInput() error {
|
|||||||
if strings.HasPrefix(inputString, cmdPrefix) {
|
if strings.HasPrefix(inputString, cmdPrefix) {
|
||||||
cmd := strings.Split(inputString[len(cmdPrefix):], " ")
|
cmd := strings.Split(inputString[len(cmdPrefix):], " ")
|
||||||
if c, ok := commands[cmd[0]]; ok {
|
if c, ok := commands[cmd[0]]; ok {
|
||||||
c.Exec(g, cmd)
|
c.Exec(cmd)
|
||||||
return nil
|
return nil
|
||||||
} else if cmd[0] == "q" || cmd[0] == "quit" {
|
} else if cmd[0] == "q" || cmd[0] == "quit" {
|
||||||
return gocui.ErrQuit
|
return gocui.ErrQuit
|
||||||
@ -395,5 +395,5 @@ func RegisterCommand(c Command) error {
|
|||||||
|
|
||||||
// RunCommand calls a command as if it was run by the user
|
// RunCommand calls a command as if it was run by the user
|
||||||
func RunCommand(c ...string) {
|
func RunCommand(c ...string) {
|
||||||
commands[c[0]].Exec(g, c)
|
commands[c[0]].Exec(c)
|
||||||
}
|
}
|
||||||
|
|||||||
12
types.go
12
types.go
@ -1,13 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/jroimartin/gocui"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Command outlines a command
|
// Command outlines a command
|
||||||
type Command struct {
|
type Command struct {
|
||||||
Cmd []string // Any aliases that trigger this command
|
Cmd []string // Any aliases that trigger this command
|
||||||
Description string // A short description of the command
|
Description string // A short description of the command
|
||||||
Help string // The full help text explaining how to use the command
|
Help string // The full help text explaining how to use the command
|
||||||
Exec func(*gocui.Gui, []string) // A function that takes the command (arg[0]) and any arguments (arg[1:]) as input
|
Exec func([]string) // A function that takes the command (arg[0]) and any arguments (arg[1:]) as input
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user