This tool downloads the latest Xcode CLI Tools and two supporting SDK packages to your desktop. Note Pay careful attention to the packages downloaded, as it will find all matching Xcode CLI related installers.
These tools are usually behind the Apple Developer portal, and come in a DMG file containing a single pkg installer.
git clone https://github.com/carlashley/xcode_tools && cd xcode_tools
chmod +x xcodetools.py
What this does
This utility parses the Software Update catalog for specific macOS versions (if none provided, defaults to your version of macOS), finds the XCode Command Line Tools and SDK files (or all those applicable), and downloads them.
This can also be used to install the tools.
If no arguments are provided, the default behaviour is to download the Command Line Tools and SDK (if available) for the release of macOS the script is run on.
--catalog argument is pretty much pointless as the packages are all (based on checking out the merged 10.14 through Leopard catalogs) pulling from the same URL's.
Don't panic if
beta|customerseed|developerseed catalogs returns no results.
Why not just run
xcode-select --install ??
Because any opportunity to avoid pesky GUI dialog boxes is one worth taking!