Giter VIP home page Giter VIP logo

rep's Issues

Insallation not working

When I tried to build with make && sudo make install I got a bunch of errors:

~/rep > make                                                                                                                                     emiller at emiller-mac (main)
cc -g -O2 -o rep rep.c
rep.c:406:17: error: implicit declaration of function 'recv' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    int count = recv(reader->fd, &ch, 1, 0);
                ^
rep.c:626:20: error: incomplete result type 'struct sockaddr_in' in function definition
struct sockaddr_in options_address_from_file(struct options* options, const char* filename)
                   ^
rep.c:610:8: note: forward declaration of 'struct sockaddr_in'
struct sockaddr_in options_address(struct options* options, const char* port);
       ^
rep.c:631:12: error: calling 'options_address' with incomplete return type 'struct sockaddr_in'
    return options_address(options, linebuffer);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rep.c:610:20: note: 'options_address' declared here
struct sockaddr_in options_address(struct options* options, const char* port);
                   ^
rep.c:610:8: note: forward declaration of 'struct sockaddr_in'
struct sockaddr_in options_address(struct options* options, const char* port);
       ^
rep.c:634:20: error: incomplete result type 'struct sockaddr_in' in function definition
struct sockaddr_in options_address_from_relative_file(struct options* options, const char* directory_in, const char* filename)
                   ^
rep.c:610:8: note: forward declaration of 'struct sockaddr_in'
struct sockaddr_in options_address(struct options* options, const char* port);
       ^
rep.c:652:32: error: variable has incomplete type 'struct sockaddr_in'
            struct sockaddr_in result = options_address_from_file(options, path_to_check);
                               ^
rep.c:610:8: note: forward declaration of 'struct sockaddr_in'
struct sockaddr_in options_address(struct options* options, const char* port);
       ^
rep.c:686:20: error: incomplete result type 'struct sockaddr_in' in function definition
struct sockaddr_in options_address(struct options* options, const char* port)
                   ^
rep.c:610:8: note: forward declaration of 'struct sockaddr_in'
struct sockaddr_in options_address(struct options* options, const char* port);
       ^
rep.c:695:28: error: variable has incomplete type 'struct sockaddr_in'
        struct sockaddr_in result = options_address_from_relative_file(options, absolute_directory, filename);
                           ^
rep.c:610:8: note: forward declaration of 'struct sockaddr_in'
struct sockaddr_in options_address(struct options* options, const char* port);
       ^
rep.c:702:23: error: use of undeclared identifier 'AF_INET'
        .sin_family = AF_INET,
                      ^
rep.c:703:34: error: use of undeclared identifier 'INADDR_LOOPBACK'
        .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
                                 ^
rep.c:703:34: error: use of undeclared identifier 'INADDR_LOOPBACK'
rep.c:703:34: error: use of undeclared identifier 'INADDR_LOOPBACK'
rep.c:703:34: error: use of undeclared identifier 'INADDR_LOOPBACK'
rep.c:703:34: error: use of undeclared identifier 'INADDR_LOOPBACK'
rep.c:703:34: error: use of undeclared identifier 'INADDR_LOOPBACK'
rep.c:700:24: error: variable has incomplete type 'struct sockaddr_in'
    struct sockaddr_in address =
                       ^
rep.c:610:8: note: forward declaration of 'struct sockaddr_in'
struct sockaddr_in options_address(struct options* options, const char* port);
       ^
rep.c:719:35: error: implicit declaration of function 'gethostbyname' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            struct hostent *ent = gethostbyname(host_part);
                                  ^
rep.c:719:35: note: did you mean 'gethostname'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:626:6: note: 'gethostname' declared here
int      gethostname(char *, size_t);
         ^
rep.c:719:29: warning: incompatible integer to pointer conversion initializing 'struct hostent *' with an expression of type 'int' [-Wint-conversion]
            struct hostent *ent = gethostbyname(host_part);
                            ^     ~~~~~~~~~~~~~~~~~~~~~~~~
rep.c:722:28: error: incomplete definition of type 'struct hostent'
            if (NULL == ent->h_addr)
                        ~~~^
rep.c:719:20: note: forward declaration of 'struct hostent'
            struct hostent *ent = gethostbyname(host_part);
                   ^
rep.c:727:53: error: incomplete definition of type 'struct hostent'
            address.sin_addr.s_addr = *(u_long *)ent->h_addr_list[0];
                                                 ~~~^
rep.c:719:20: note: forward declaration of 'struct hostent'
            struct hostent *ent = gethostbyname(host_part);
                   ^
rep.c:947:17: error: implicit declaration of function 'socket' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    nrepl->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make: *** [rep] Error 1

When I tried using nix, I got an error:

~/rep ! > nix-build .                                                                                                                            emiller at emiller-mac (main)
error: opening file '/Users/emiller/rep/default.nix': No such file or directory

I wish there was a version for Windows as well.

Since the clojure program at the company I work for is a windows version, I wish there was a Windows version as well.
When did the Mac version come out?! It's so good.
I wish I could compile it. Is there no way?

I'm also watching a rust client called ruply.
But now ruply is executed twice. (It seems that it is possible to create a Windows binary called Rust)
�Thank you.

Add REPL buffer to kakoune

I've extended rep to have it write repl I/O to a dedicated *rep* buffer in kakoune. This is necessary for how our clojure build system works at my job for... reasons. But it also has some advantages, like being able to interact with repl output with the full facilities of kakoune.

I'd be happy to clean this up and submit a PR if you think it's in scope for this project.

Long operations

First things first, awesome tool, thank you for sharing this. It's very useful.

I'm sending a command to a remote repl that takes a long time to complete. The client (rep) doesn't complain, but the nrepl server reports a SocketException: Socket closed after the operation completes. Any idea how to handle this properly? Thank you.

Note: Short operations do not display that behavior.

Stack error in full:

2019-12-26_15:00:15.06063 java.net.SocketException: Socket closed
2019-12-26_15:00:15.06063       at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113) ~[na:na]
2019-12-26_15:00:15.06063       at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:150) ~[na:na]
2019-12-26_15:00:15.06064       at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81) ~[na:na]
2019-12-26_15:00:15.06064       at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142) ~[na:na]
2019-12-26_15:00:15.06065       at nrepl.transport$bencode$fn__460.invoke(transport.clj:116) ~[na:na]
2019-12-26_15:00:15.06065       at nrepl.transport.FnTransport.send(transport.clj:41) ~[na:na]
2019-12-26_15:00:15.06066       at nrepl.middleware.print$send_nonstreamed.invokeStatic(print.clj:159) ~[na:na]
2019-12-26_15:00:15.06068       at nrepl.middleware.print$send_nonstreamed.invoke(print.clj:138) ~[na:na]
2019-12-26_15:00:15.06069       at nrepl.middleware.print$printing_transport$reify__851.send(print.clj:174) ~[na:na]
2019-12-26_15:00:15.06070       at cider.nrepl.middleware.track_state$make_transport$reify__5617.send(track_state.clj:228) ~[na:na]
2019-12-26_15:00:15.06071       at nrepl.middleware.caught$caught_transport$reify__886.send(caught.clj:58) ~[na:na]
2019-12-26_15:00:15.06071       at nrepl.middleware.interruptible_eval$evaluate$fn__942.invoke(interruptible_eval.clj:123) ~[na:na]
2019-12-26_15:00:15.06072       at clojure.main$repl$fn__9095.invoke(main.clj:460) ~[ninjasocks-1.7.1.jar:na]
2019-12-26_15:00:15.06072       at clojure.main$repl.invokeStatic(main.clj:458) ~[ninjasocks-1.7.1.jar:na]
2019-12-26_15:00:15.06072       at clojure.main$repl.doInvoke(main.clj:368) ~[ninjasocks-1.7.1.jar:na]
2019-12-26_15:00:15.06072       at clojure.lang.RestFn.invoke(RestFn.java:1523) ~[ninjasocks-1.7.1.jar:na]
2019-12-26_15:00:15.06073       at nrepl.middleware.interruptible_eval$evaluate.invokeStatic(interruptible_eval.clj:79) ~[na:na]
2019-12-26_15:00:15.06073       at nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:55) ~[na:na]
2019-12-26_15:00:15.06074       at nrepl.middleware.interruptible_eval$interruptible_eval$fn__949$fn__953.invoke(interruptible_eval.clj:142) ~[na:na]
2019-12-26_15:00:15.06074       at clojure.lang.AFn.run(AFn.java:22) ~[ninjasocks-1.7.1.jar:na]
2019-12-26_15:00:15.06074       at nrepl.middleware.session$session_exec$main_loop__1050$fn__1054.invoke(session.clj:171) ~[na:na]
2019-12-26_15:00:15.06075       at nrepl.middleware.session$session_exec$main_loop__1050.invoke(session.clj:170) ~[na:na]
2019-12-26_15:00:15.06076       at clojure.lang.AFn.run(AFn.java:22) ~[ninjasocks-1.7.1.jar:na]
2019-12-26_15:00:15.06076       at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

Doc improvement ideas

After reading the docs I can suggest a couple of things:

  • explain in more details that the client connects to the server every time, as that's not really apparent
  • explain a bit how editors can leverage rep by shelling out to it

Btw, I was puzzled about the lein remark and the fact you had to patch transport.clj - doesn't this work fine with Lein 2.8.3 and nREPL 0.5.3 that's bundled there?

Publish new binaries on GitHub?

It would be convenient to have the latest binaries published on GitHub.

The current ones with v0.1.2 seem to be old (2019 while there were changes in rep.c in 2021) and the Ubuntu binary rep-0.1.2-linux-amd64.tar.gz is out-of-sync with macOS binary.

macOS:

ᐅ rep -h
rep: Single-shot nREPL client
Synopsis:
  rep [OPTIONS] [--] [CODE ...]
Options:
  -h, --help                      Show this help screen.
  -l, --line=[FILE:]LINE[:COLUMN] Set reference file, line, and column for errors.
  -n, --namespace=NS              Evaluate code in NS (default: user).
  --no-print=KEY                  Suppress output for KEY.
  --op=OP                         nREPL operation (default: eval).
  -p, --port=ADDRESS              TCP port, host:port, @portfile, or @FNAME@RELATIVE.
  --print=KEY|KEY,FD,FORMAT       Print FORMAT to FD when KEY is present.
  --send=KEY,TYPE,VALUE           Send additional KEY of VALUE in request.
  -v, --verbose                   Show all messages sent and received.

Ubuntu:

# ./rep -h
rep: Single-shot nREPL client
Syntax:
  rep [OPTIONS] CODE ...

Options:
  -h, --help                                   Show this help screen.
  -l, --line LINE[:COLUMN]       1             Specify code's starting LINE and COLUMN.
  -n, --namespace NS             user          Evaluate expressions in NS.
      --op OP                    eval          Send OP as the nREPL operation.
  -p, --port [HOST:]PORT|@FILE   @.nrepl-port  Connect to HOST at PORT, which may be read from FILE.
      --print KEY[,FD[,FORMAT]]  ["out,1,%{name}" "err,2,%{err}" "value,1,%{value}%n"]  Print KEY from response messages to FD using FORMAT.
      --send KEY,TYPE,VALUE                    Send KEY: VALUE in request.

Guix alnog Nix?

Would be nice if I could build it with Guix. I think it provides all you need from Nix

Doesn't resolve nrepl port from nested folder, by default

Steps to reproduce:

  1. Start repl from root of a project: lein repl
  2. Navigate to nested folder: cd src
  3. Try to evaluate an expression: rep '(+ 1 1)'

Actual output:

.nrepl-port: No such file or directory

Expected output:

2

Observation:
Providing default input for port argument fixes it:

> rep -p @.nrepl-port@. '(+ 1 1)'
2

pprint the result

Is there the way to get formatted result?

Usually it's done with (set! nrepl.middleware.print/*print-fn* clojure.pprint/pprint).

I can prepend every call with this, but it's not too much usable.

$ rep "(set! nrepl.middleware.print/*print-fn* clojure.pprint/pprint)(def a 1)(def b 2)"
#function[clojure.pprint/pprint]

#'user/a

#'user/b

Or different variant - is there a way to get only result of the last call?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.