Search code examples
luaformatpretty-print

How to use lunadry?


I'm trying to use Lua Lunadry to reformat some really ugly code, but I'm getting this error everytime I try:

Formatting i,h
./lunadry: line 85: i,h: No such file or directory

I've tried argument I could think of, and I feel like I am missing something very simple :P

I read the README which says to use it by doing:

./lunadry --in-place file.lua

But again, every time I get the same error. Could someone tell me how to use this properly?


Solution

  • lunadry expects GNU getopt behaviour.

    OS X (and other BSD systems) have non-GNU getopt installed by default. This version of getopt is lacking many features and (at least historically) was fairly broken.

    Available solutions are:

    • install GNU getopt (possibly through homebrew or similar system).
    • rewrite script to use bash built-in getopts (will lose ability to parse --long-options)
    • rewrite script to use manual option parsing (naively will lose ability to parse -ih but in this case that won't hurt much)
    • file an issue asking batrick to do one of those rewrites