SwiftDefaultApps includes two tools: a command-line binary (swda) and a preference pane. If your intent is only to set or maintain certain administrative defaults, the command-line tool is sufficient. The preference pane is only needed if you want to also provide a user-friendly interface for handling these changes.
Or we could just take a more manual/lower level approach:
/System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister -kill -r -domain local -domain system -domain user
Preferences are stored in a set of files under ~/Library/Preferences, however using the defaults command is much safer than manually editing a .plist file. The cfprefsd daemon manages and caches updates to preference files. If you modify the file directly, the changes will not propagate through the cache managed by the daemon.
Use https://github.com/moretension/duti to dump/restore custom file type applications, though it seems as though it may not be maintained anymore:
brew install duti
See also:
Could also use something like https://github.com/Lord-Kamina/SwiftDefaultApps to make it easier to configure in general, though it seems to have it's own issues too:
brew install --cask swiftdefaultappsprefpane
Seemingly it also includes a CLI tool
swda
.Or we could just take a more manual/lower level approach:
mdls -name kMDItemCFBundleIdentifier /Applications/Sublime\ Text.app
mdls -name kMDItemContentType -name kMDItemContentTypeTree ~/Desktop/foo.txt
defaults write com.apple.LaunchServices LSHandlers -array-add '{ LSHandlerContentType = \"public.plain-text\"; LSHandlerRoleAll = \"com.sublimetext.4\"; }'
/System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister -kill -r -domain local -domain system -domain user