Further side-quest to become comfortable with IEx/mix/dbg/pry. Learning commandline debugging since I’ve not been able to figure out how to launch a debuggable commandline program from VSCode.
IEx
A quick introduction to IEx functionality: 8 + 1 things….
# Start and run the mix script:
iex -S mix
# Run specific function
iex -S mix run -e "Issues.CLI.run(['arg1', 'arg2'])"
# Recompile changed mix project files.
recompile
Mix
# Create new project tree
mix new project_name
mix test
# Show dependencies
mix deps
# Fetch dependencies
mix deps.get
# Run Chapter 13 exercise:
mix run -e 'Issues.CLI.run(["rgacote", "ProgrammingElixirExercises"])'
Debugging
Use the Elixir
dbg()
statement.IEx drops you into pry.
# See variable bindings binding() # Execution stack whereami()
Cannot continue after a piped
dbg()
because it returns ``:ok`.Use
break!
from IEx.break! Issues.CLI.run/1
Pry is not a debugger. You can only examine local information.
Creating a CLI
Builds the commandline interface in the home directory.
Add a
main(argv)
function to the CLI module.Add line to mix.exs
def project
section:escript: [main_module: Issues.CLI],
Build:
mix escript.build
All notes and comments are my own opinion. Follow me at @rgacote@genserver.social