Update application
This commit is contained in:
parent
6d4cf4e35b
commit
0c874120cf
21
Makefile
21
Makefile
@ -3,7 +3,8 @@ default: test
|
||||
# -timeout timout in seconds
|
||||
# -v verbose output
|
||||
test:
|
||||
go test -timeout=5s -v
|
||||
@echo "+ $@"
|
||||
@ go test -timeout=5s -v
|
||||
|
||||
# `CGO_ENABLED=0`
|
||||
# Because of dynamically linked libraries, this will statically compile the
|
||||
@ -34,19 +35,27 @@ test:
|
||||
# `./src/`
|
||||
# Location of the source files
|
||||
build:
|
||||
CGO_ENABLED=0 go build -a -installsuffix cgo -o ./bin/slack-term ./src/
|
||||
@ echo "+ $@"
|
||||
@ CGO_ENABLED=0 go build -a -installsuffix cgo -o ./bin/slack-term ./src/
|
||||
|
||||
# Cross-compile
|
||||
# http://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5
|
||||
build-linux:
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -o ./bin/slack-term-linux-amd64 ./src/
|
||||
@ echo "+ $@"
|
||||
@ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -o ./bin/slack-term-linux-amd64 ./src/
|
||||
|
||||
build-mac:
|
||||
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -o ./bin/slack-term-darwin-amd64 ./src/
|
||||
@ echo "+ $@"
|
||||
@ GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -o ./bin/slack-term-darwin-amd64 ./src/
|
||||
|
||||
run: build
|
||||
./bin/slack-term
|
||||
@ echo "+ $@"
|
||||
@ ./bin/slack-term
|
||||
|
||||
install:
|
||||
@ echo "+ $@"
|
||||
@ go install .
|
||||
|
||||
build-all: build build-linux build-mac
|
||||
|
||||
.PHONY: default test build build-linux build-mac run
|
||||
.PHONY: default test build build-linux build-mac run install
|
||||
|
@ -31,7 +31,12 @@ Usage
|
||||
| `esc` | normal mode |
|
||||
| `k` | move channel cursor up |
|
||||
| `j` | move channel cursor down |
|
||||
| `pg-up` | scroll up chat pane |
|
||||
| `pg-down` | scroll down chat pane |
|
||||
| `pg-up` | scroll chat pane up |
|
||||
| `ctrl-b` | scroll chat pane up |
|
||||
| `ctrl-u` | scroll chat pane up |
|
||||
| `pg-down` | scroll chat pane down |
|
||||
| `ctrl-f` | scroll chat pane down |
|
||||
| `ctrl-d` | scroll chat pane down |
|
||||
| `pg-down` | scroll chat pane down |
|
||||
| `q` | quit |
|
||||
|
||||
|
35
TODO.md
35
TODO.md
@ -1,35 +0,0 @@
|
||||
Bugs:
|
||||
|
||||
- [x] when switching channels sometimes messages are persisted in the new
|
||||
channel, the Buffer() in Chat will probably not go further than the
|
||||
latest message. Could be that items are added to List and not cleared
|
||||
when switching channels
|
||||
- [x] send message as user, now it will send it as a bot
|
||||
- [x] alot of usernames 'unknown' should be a better way to uncover this
|
||||
- [x] message creation in input.go and events.go should be made into function
|
||||
CreateMessage
|
||||
- [x] restarting the application will always add the latest sent message
|
||||
through RTM in the selected channel
|
||||
- [x] uncovering usernames takes too long, should find a better way
|
||||
test without uncovering, if that is the problem
|
||||
- [x] GetMessages for a channel can result in `json: cannot unmarshal number
|
||||
into Go value of type string` https://github.com/nlopes/slack/issues/92
|
||||
- [x] set channelname on start
|
||||
- [x] incoming message event.go probably need a type switch
|
||||
- [ ] GetMessages for a channel doesn't have to load messages based on height
|
||||
of chat pane (y). Because message will sometimes span more than one
|
||||
line and we're able to scroll. Only figure out how many messages you
|
||||
want to load.
|
||||
- [ ] implement the other keys
|
||||
- [ ] docs at exported functions
|
||||
|
||||
Features:
|
||||
|
||||
- [x] channel name in chat pane
|
||||
- [x] new message indicator
|
||||
- [x] scrolling in chat pane
|
||||
- [x] group channels, im channels
|
||||
- [x] scrolling in channel pane
|
||||
- [x] command mode center text
|
||||
- [ ] remove unsubscribed or closed channels/groups/im
|
||||
- [ ] remapping of keys
|
49
src/main.go
49
src/main.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/user"
|
||||
"path"
|
||||
@ -12,14 +13,29 @@ import (
|
||||
"github.com/gizak/termui"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Start terminal user interface
|
||||
err := termui.Init()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer termui.Close()
|
||||
const (
|
||||
USAGE = `NAME:
|
||||
slack-term - slack client for your terminal
|
||||
|
||||
USAGE:
|
||||
slack-term -config [path-to-config]
|
||||
|
||||
VERSION:
|
||||
%s
|
||||
|
||||
GLOBAL OPTIONS:
|
||||
--help, -h
|
||||
`
|
||||
)
|
||||
|
||||
var (
|
||||
flgConfig string
|
||||
flgUsage bool
|
||||
|
||||
VERSION = "dev"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Get home dir for config file default
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
@ -27,15 +43,30 @@ func main() {
|
||||
}
|
||||
|
||||
// Parse flags
|
||||
flgConfig := flag.String(
|
||||
flag.StringVar(
|
||||
&flgConfig,
|
||||
"config",
|
||||
path.Join(usr.HomeDir, "slack-term.json"),
|
||||
"location of config file",
|
||||
)
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Printf(USAGE, VERSION)
|
||||
}
|
||||
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Start terminal user interface
|
||||
err := termui.Init()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer termui.Close()
|
||||
|
||||
// Create context
|
||||
ctx := context.CreateAppContext(*flgConfig)
|
||||
ctx := context.CreateAppContext(flgConfig)
|
||||
|
||||
// Setup body
|
||||
termui.Body.AddRows(
|
||||
|
Loading…
Reference in New Issue
Block a user