@@ -9,19 +9,22 @@ import (
99 "net/rpc"
1010 "os"
1111
12+ "github.com/pocke/lemonade/lemon"
1213 "github.com/pocke/lemonade/param"
1314 "github.com/pocke/lemonade/server"
1415)
1516
1617type client struct {
17- host string
18- port int
18+ host string
19+ port int
20+ lineEnding string
1921}
2022
21- func New (host string , port int ) * client {
23+ func New (c * lemon. CLI ) * client {
2224 return & client {
23- host : host ,
24- port : port ,
25+ host : c .Host ,
26+ port : c .Port ,
27+ lineEnding : c .LineEnding ,
2528 }
2629}
2730
@@ -94,7 +97,7 @@ func (c *client) Paste() (string, error) {
9497 return "" , err
9598 }
9699
97- return resp , nil
100+ return lemon . ConvertLineEnding ( resp , c . lineEnding ) , nil
98101}
99102
100103func (c * client ) Copy (text string ) error {
@@ -108,7 +111,7 @@ func (c *client) withRPCClient(f func(*rpc.Client) error) error {
108111 if err != nil {
109112 log .Println (err )
110113 log .Println ("Fall back to localhost" )
111- rc , err = fallbackLocal ()
114+ rc , err = c . fallbackLocal ()
112115 if err != nil {
113116 return err
114117 }
@@ -121,8 +124,9 @@ func (c *client) withRPCClient(f func(*rpc.Client) error) error {
121124 return nil
122125}
123126
124- func fallbackLocal () (* rpc.Client , error ) {
127+ func ( c * client ) fallbackLocal () (* rpc.Client , error ) {
125128 port , err := server .ServeLocal ()
129+ server .LineEndingOpt = c .lineEnding
126130 if err != nil {
127131 return nil , err
128132 }
0 commit comments