Overview
Users should be able to use the CLI with any WriteFreely instance -- not just Write.as.
This should involve a rebranding of the Write.as CLI to make it clear to users that the client works with any instance -- perhaps create a new writefreely executable in the cmd/ directory that shares code with the writeas CLI and only includes functionality that works on WF.
Implementation
- Create a new .writefreely directory in the user's home directory
- Add a -host or -h flag that allows user to specify which instance to interact with
- When they successfully perform an action on an instance, save that information to a folder in ~/.writefreely:
- instance directory: ~/.writefreely/[host]
- posts: ~/.writefreely/[host]/[username]/posts.json
- user data: ~/.writefreely/[host]/[username]/user.json
- Future interactions with that instance should load the corresponding data from the instance's data directory
posts.json
Should contain the JSON array of posts returned in the data property from the /api/me/posts endpoint.
user.json
Should contain the full JSON object returned in the data property from the /api/auth/login endpoint (as currently happens when running writeas auth). This includes the access_token needed for all authenticated requests.
Questions
We should probably provide a way to indicate the default instance and username for CLI operations, so users don't have to include them every time.