3 ms·
I rewrote all my CLI scripts in Elixir, it's best in class IMO. With Mix.install now it's just amazing. Fast, free and simple concurrency, low startup time, gre
by amalgamated_inc 4y ago
I rewrote all my CLI scripts in Elixir, it's best in class IMO. With Mix.install now it's just amazing. Fast, free and simple concurrency, low startup time, great ecosystem, very good system level abstractions and functions in the stdlib.
- xcdzvyn 4y agoI completely agree with GP in that Elixir isn't really _designed_ for CLI tools, but I agree with you that it does happen to be great for it. I don't doubt there are some facilities it lacks that would make ones life easier, but overwhelmingly its standard library is more than sufficient.
- realitylabs 4y agoAre any of these published or would you share an example?
- amalgamated_inc 4y agoNothing published, they're typically not very complex. Things of interest for CLI stuff: #!/usr/bin/env elixir Use Mix.install like so Mix.install([ {:jason, "~> 1.4"}, ]) Execute shell commands {output, status_code} = System.cmd("ls", ["-la"]) For handling files and paths: Path.join/2 __ENV__.file Path.dirname/1 Path.expand/1 File.lstat/1 File.read/1 Parsing arguments argv = System.argv() OptionParser.parse(argv, [strict: [switch: :boolean], aliases: [s: :switch]]) exit({:shutdown, status_code}) # for shutting down with an error For printing colors (from docs) iex> IO.ANSI.format(["Hello, ", :red, :bright, "world!"], true)