← All series

Series contents

Log in to track your progress

  1. 1. Welcome to Alchemist Camp Episode
  2. 2. Lesson 1: The guessing game Episode
  3. 3. Solution 1: The Greeter Episode
  4. 4. Lesson 2: Word Count Episode
  5. 5. Word Count ULTIMATE EDITION! Episode
  6. 6. Minimal Todo List Part 1 Episode
  7. 7. Elixir lists vs Elixir tuples Article
  8. 8. The Image Snatcher Episode
  9. 9. Minimal Todo List Part 2 Episode
  10. 10. Elixir maps made effortless Article
  11. 11. Fibonacci with tail recursion Episode
  12. 12. Mini Markdown Episode
  13. 13. Extending Mini Markdown Episode
  14. 14. Alchemy Markdown Episode
  15. 15. Using mix to modularize and add tests Episode
  16. 16. Command line applications with escript Episode
  17. 17. Caboose, a simple Unix tail clone Episode
  18. 18. Game board (Tictac Part 1) Episode
  19. 19. Structs: Maps with checks and default values Article
  20. 20. Deck generation, Pythagorean Triplets and more Episode
  21. 21. Whiteboarding the Tictac state machine Episode
  22. 22. Game state machine (Tictac Part 2) Episode
  23. 23. Modelling the memory game Episode
  24. 24. Finishing Tictac and making a CLI Episode
  25. 25. Threatened by rooks, bishops and knights Episode
  26. 26. A worker to log stats from a YouTube’s API Episode
  27. 27. Constructing bitmap files with Elixir Episode
  28. 28. Making bitmaps with color palettes Episode
  29. 29. Flattening lists recursively in Elixir Episode

Caboose, a simple Unix tail clone

We use Elixir's escript to create a command line application to solve the challenge from lesson 7. It's a clone of the core functionality of Unix's "tail" command.

Unlike the "wc" clone we built previously, tail requires the ability to parse flags with arguments, e.g. tail filename.txt -n 30. We also introduce the one-liner syntax for if-else blocks.

Open standalone page ↗

3 Comments

I found that if I used the switch "--lines2323" for example, it would still read the file and show the last 10 lines. In your example, it shows the help message. I changed "switches" to "strict" in cli.ex, and now it shows the help message as expected, along with working as expected. I also found the same in the Word Count example, but didn't find the problem until now... Might be due to the version of Elixir I am using is 1.10, and not 1.5 as used in the video, and OptionParser.parse may have changed functionality in that time.

- owen · 6 years ago

I've had a look at ASDF, but haven't set it up as yet. I'm only just coming back into programming after about 20 years - did a lot of Assembly and C++ back then. Slowly working my way through screen casts and books to get my head around Elixir & Phoenix for some projects I've been wanting to do for years. Elixir and Phoenix are definitely a great fit for them! And thanks for all your hard work on these videos!!

- owen · 6 years ago

Great discovery, Owen! Have you gone through the ASDF setup video yet? It makes switching versions trivial and you can define them per project with a .tool-versions file.

In general, you don't need to worry about any breaking changes from language versions. Until there's a v2, if there ever is, anything after 1.0 should be fine.

- alchemist · 6 years ago