Lego can be use as a CLI.
Read this first to clarify some assumptions made by the following guides.
This guide explains various ways to obtain a new certificate.
This guide describes how to renew existing certificates.
This page describes various command line options.