Got a lot of houseplants? Generate a watering schedule--in Clojure! By the end of writing this program, you will be able to:
- Set up Clojure project with dependencies
- Call an API
- Turn api data into something useful
- Output a file onto your machine
- clj -m --help ;; lists commands
- clj -m --houseplants ;; lists houseplants the program knows about
- clj -m --schedule [array of houseplants] ;; produces your houseplant watering schedule
(How tools.deps works)[https://clojure.org/reference/deps_and_cli] (The little API this project is calling)[]
Every Clojure project has the following:
- (src directory)[]: contains all the "business logic*" namespaces
- (test directory)[]: contains one test for each namespace
- (dependencies file)[]: we are using tools.deps. There is another dependency manager called leiningen that uses a file called project.clj instead of deps.clj. You can read more about it in the dependencies section of the Beginner's Guide.
This project has four namespaces:
client
: communicates with the api to retrieve datascheduler
: uses the data retrieved byclient
to build your houseplant scheduleprinter
: formats your houseplant schedule and prints it to a file on your computermain
: listens to command line arguments and runs the program based on the arguments it receives. Most Clojure programs have amain
namespace.
To understand why the project is organized this way, please refer to the Separation of concerns
section in the Beginner's Guide
This project also has a seed data file to use for tests and can be run in the REPL in case there is no API available. See the REPL
section in the Beginner's Guide.