7 ms·
Owl: A toolkit for writing command-line user interfaces in Elixir
- escherize 4y agoIs there something like this for Java?
- Celeo 4y agoMany, yes. You can pair a CLI arg parser with a logger that supports colored output, and add a TUI library if you needed that. There are "command line frameworks" as well, like picocli that can be paired with something like Jbang for distribution.
- electrum 4y agoJLine has a complete terminal library and includes a demo which is a full editor: https://github.com/jline/jline3 https://github.com/jline/jline3
- eternalban 4y agohttps://github.com/remkop/picocli https://github.com/remkop/picocli "Picocli is a one-file framework for creating Java command line applications with almost zero code. Picocli aims to be the easiest way to create rich command line applications that can run on and off the JVM. Picocli supports a variety of command line syntax styles including POSIX, GNU, MS-DOS and more. It generates highly customizable usage help messages with ANSI colors and styles. Picocli-based applications can have command line TAB completion showing available options, option parameters and subcommands, for any level of nested subcommands. Picocli-based applications can be ahead-of-time compiled to a GraalVM native image, with extremely fast startup time and lower memory requirements, which can be distributed as a single executable file. Picocli generates beautiful documentation for your application (HTML, PDF and Unix man pages)." https://picocli.info/quick-guide.html https://picocli.info/quick-guide.html
- shijie 4y agoIt seems that every ShowHN that features an Elixir project is well-polished, has a sensical API, and has friendly, solid documentation. Is this a function of the nature of the language, the community, or a mix of both?
- hazn 4y agoThe Elixir community has good internal (and official!) tooling around libraries and documentation. I would say it's a positive feedback loop. The nice community resources attract good programmers, good programmers make nice community resources.
- ctvo 4y agoOr it's the way upvotes work for the most part?
- kitplummer 4y agoAbsolutely both. But...the issue is packaging/distributing a CLI built with Elixir. Comparatively to building a CLI in something like Rust, there is a lot of overhead that comes with a VM-based language and framework. Especially if you want to target multiple OS and processor architectures (or distributions). Not to say that it is impossible, just maybe not as simple. It is one thing to run Mix tasks, or access the Owl API from REPL, it is another to run an Owl-based app on macOS, Linux and Windows and get it there.
- kirushik 4y agoWell, `mix release` (https://hexdocs.pm/mix/Mix.Tasks.Release.html https://hexdocs.pm/mix/Mix.Tasks.Release.html) exists to address this very issue. It still has limitations (the biggest one is the requirement for the os&architecture to match between the builder and the deployment target) — but the result is a standalone binary which not only embeds the VM and preloads the app's bytecode, but even "trims" the stdlib to only ship the required functions.
- kitplummer 4y agoRight, so the moral of the story centers on the target user of the CLI tool. If you're building something for the Elixir community - game on I suppose, though there is still the complexity of build-env per OS/arch. I wonder where WASM/container enters the discussion.
- kemiller 4y agoThis is very welcome. Elixir is ill-suited to command line apps out of the box.
- andy_ppp 4y agoHow problematic is the BEAM startup time for this? I made a command line tool once and it took a while to start the VM but this was on a much older machine...
- lytedev 4y agoIt's going to completely depend on the tool. I can start an elixir app in half a second, which is going to be unacceptable in many situations. That said, there are also many situations where that is a tradeoff absolutely worth making!
- throwawaymaths 4y agoI wonder if you can tree-shake unnecessary modules in the release. There's a lot of stuff in the otp beam release you probably don't need in any given CLI app and it should be easy to parse bytecode and figure out dependencies.
- manusachi 4y agoThat's one of the goals of Firefly[1] > It can compile code more efficiently than the BEAM by stripping out dead code and compiling only what’s necessary for an application. Though, they only mention faster compilation and smaller digital footprint, not faster startup. [1] https://dockyard.com/blog/2022/09/01/dockyard-r-d-firefly-optimizes-your-elixir-compilation https://dockyard.com/blog/2022/09/01/dockyard-r-d-firefly-op...
- asabil 4y agoShouldn’t be necessary if you configure your release to start in interactive move instead of embedded mode as modules would then get loaded lazily
- worthless-trash 4y agoHello friend, I'm chasing you down from a previous comment, did you get anywhere with that elixir/liveview text ui ?
- lycos 4y agoI love using Elixir but I also like to think "right tool for the job" and imho Elixir is generally not the right tool for the job for command-line user interfaces. It's fun to experiment with though, of course. Having said all of that that, something like this might be useful when writing custom Mix tasks inside Elixir projects!
- Existenceblinks 4y agoI wonder which one is currently the king (include all arbitrary metrics you can think of)? I guess 1.Go 2.Rust
- RexM 4y agoBash?
- c0balt 4y agoWon't work on windows outside of WSL, at least that has been a reason I've heard for not using Bash for simple stuff. For complex applications bash (or shellscript in general) is also rather ill-suited as it has a lot of footguns and can be hard to maintain.
- cglong 4y agoYou can also use Bash in Cygwin/MSYS environments, like Git for Windows. I've been using Bash for writing cross-platform Git scripts :)
- thesneakin 4y agoFor decades. Bash even runs in DOS.
- Existenceblinks 4y agoI have no idea if Bash has library? It's more like for managing host stuff rather than compute wide range of application.
- vlad 4y agoBuilding a cross-platform CLI from a python script in 2009 required unrelated open-source tools to package for each of the three major operating systems. I remember asking Dropbox guys what they were using. Having an official way to do it is much better. Regardless of technology, I think CLI's tend to maintain their original size, or get smaller over time. If you choose to use a CLI built with Elixir, I imagine it could gain a web-based GUI without a large increase, if each build already includes a runtime environment and system libraries. Or if a CLI is written in another language and advertised as very compact, I imagine its size will also stay consistent, but might not gain the same fancy features. And in any case, popular compilers or packaging tools tend gain optimization improvements over time.
- remram 4y agoWhat kind of tools were needed for building CLI apps? Or do you mean for packaging those apps for end users, e.g. PyInstaller and equivalent?
- bombolo 4y agoUh? What unreleased tools did you need in 2009? Everything worked fine for me then.
- SirGiggles 4y agoDid you misread "unrelated" for "unreleased" in the first sentence?
- bombolo 4y agoYes
- revskill 4y agoGithub user interface is really not good in this case. Need a visible verticle line between begin..end block.
- hun-nemethpeter 4y agoWe have an FTXUI for C++. https://github.com/ArthurSonzogni/FTXUI https://github.com/ArthurSonzogni/FTXUI
- djm_ 4y agoThis looks great! If you're building CLI tooling in Elixir, you may also be interested in TableRex, my ASCII-table drawing library. [1] [1] https://github.com/djm/table_rex https://github.com/djm/table_rex
- vegabook 4y agoAn oblique thing I love about the Elixir ecosystem is that there is a strong focus on visual and aesthetic attention to detail. I mean look at those multibars in the asciinema. They're gorgeous for a console. In this, I'm reminded of R vs Python, where the former simply has far better graphics capabilities than the latter. In the Elixir case, I can't help but compare the look and feel of Livebooks compared with Jupyter Notebooks. The former are miles ahead in terms of a modern visual experience. It's very pleasant especially if you're expected to have an audience for your output, which kind of contrasts with python which always feels like it's built for engineers (and there's nothing wrong with that, but it is a different culture).
- Narishma 4y agoNot to be confused with this OWL: https://en.wikipedia.org/wiki/Object_Windows_Library https://en.wikipedia.org/wiki/Object_Windows_Library