7 ms·
Are any of these published or would you share an example?
by realitylabs 4y ago
Are 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)