File tree 5 files changed +54
-4
lines changed
5 files changed +54
-4
lines changed Original file line number Diff line number Diff line change 8
8
9
9
### Demo
10
10
11
- ![ demo] ( https://user-images.githubusercontent.com/12980380/31976469-6d593b0c-b940 -11e7-90ef-7a0c3fbcd392 .png )
11
+ ![ demo] ( https://user-images.githubusercontent.com/12980380/32066777-96ccc284-ba89 -11e7-8823-78fea6d48eb1 .png )
12
12
13
13
### Quick start
14
14
@@ -39,6 +39,13 @@ Write message:
39
39
$ slk write -m "how are you?"
40
40
```
41
41
42
+ Switch to channel or private chat
43
+
44
+ ```
45
+ $ slk to general // for public channel or private group
46
+ $ slk to @max // for direct messages
47
+ ```
48
+
42
49
Read last 10 messages:
43
50
44
51
```
Original file line number Diff line number Diff line change 9
9
_ "github.com/yarikbratashchuk/slk/internal/cli/listen"
10
10
_ "github.com/yarikbratashchuk/slk/internal/cli/read"
11
11
_ "github.com/yarikbratashchuk/slk/internal/cli/setup"
12
+ _ "github.com/yarikbratashchuk/slk/internal/cli/to"
12
13
_ "github.com/yarikbratashchuk/slk/internal/cli/write"
13
14
)
14
15
@@ -47,6 +48,7 @@ Commands:
47
48
listen - start listen chat for messages
48
49
read - get last 10 messages
49
50
write - write message
51
+ to - used to switch between channels
50
52
51
53
Options:
52
54
command specific, use "slk help <command>" for details
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ type userList struct {
16
16
} `json:"members"`
17
17
}
18
18
19
- func GetChatUsers (conf config.Config ) (users map [string ]config.User , err error ) {
19
+ func GetChanUsers (conf config.Config ) (users map [string ]config.User , err error ) {
20
20
data := url.Values {}
21
21
data .Set ("token" , conf .Token )
22
22
data .Set ("channel" , conf .Channel )
Original file line number Diff line number Diff line change @@ -48,9 +48,9 @@ func (c *command) Run() {
48
48
49
49
c .conf .Channel = channelID
50
50
51
- users , err := api .GetChatUsers (c .conf )
51
+ users , err := api .GetChanUsers (c .conf )
52
52
if err != nil {
53
- log .Fatalf ("error getting chat users: %s" , err )
53
+ log .Fatalf ("error getting channel users: %s" , err )
54
54
}
55
55
c .conf .Users = users
56
56
Original file line number Diff line number Diff line change
1
+ package to
2
+
3
+ import (
4
+ "fmt"
5
+ "os"
6
+ "os/exec"
7
+
8
+ "github.com/yarikbratashchuk/slk/internal/cli"
9
+ "github.com/yarikbratashchuk/slk/internal/log"
10
+ )
11
+
12
+ type command struct {}
13
+
14
+ func initCommand () cli.Command {
15
+ if len (os .Args ) != 3 {
16
+ usage ()
17
+ }
18
+ return command {}
19
+ }
20
+
21
+ func (c command ) Run () {
22
+ cmd := exec .Command ("slk" , "setup" , "-c" , os .Args [2 ])
23
+ cmd .Stdout = os .Stdout
24
+ cmd .Stderr = os .Stderr
25
+ if err := cmd .Run (); err != nil {
26
+ log .Fatalf ("slk: %s" , err )
27
+ }
28
+ }
29
+
30
+ func (c command ) Usage () {
31
+ usage ()
32
+ }
33
+
34
+ func usage () {
35
+ fmt .Printf ("Usage: %s to <channel>\n " , os .Args [0 ])
36
+ os .Exit (0 )
37
+ }
38
+
39
+ func init () {
40
+ cli .RegisterCommand ("to" , initCommand )
41
+ }
You can’t perform that action at this time.
0 commit comments