Closed ghost closed 4 years ago
also will need to verify the change with global flags doesn't break anything
fixed
found a small bug I missed, unsynced posts are stored in one file at the root, not at each host level. fix incoming.
just waiting for writeas/go-writeas#18 to verify things work as expected
updated, but I need to make a change for custom tor url now
Still need to do some more exhaustive testing, but I think most of what I found is fixed. Biggest behavior changes:
--host
now takes the host without a scheme, i.e. example.com
instead of https://example.com
. It adds an --insecure
flag to use in conjunction with --host
, in case anyone really wants that. Goal here is to save users some typing.
On first run of wf auth
, we now set the account as default, so subsequent requests are automatically made on that account without adding the --host
and --user
flags. (Discussion here.)
Also, in building this I found a bug in WF where the instance's full URL isn't returned in the API. This is fixed in writeas/writefreely#144, so wf-cli
will only work with an instance at WF v0.11 or later.
Another thing I'd like to fix: when running e.g. wf --host team.write.as logout
(i.e. with a --host
but not --user
) the error message just says I'm not logged in and need to authenticate.
If I am authenticated as a single user on that instance, I'd like it to know that and just use the account.
If I'm authenticated as multiple users on that instance, I'd like it to inform me that I need to supply the -u
/ --user
flag.
@thebaer do you want me to finish this up?
Yep, that'd be great. Just to add to my last comment, I'd like to see that behavior on all commands, not just logout
ready for final testing and review @thebaer
Okay, we're getting very close. This may be the last issue we need to solve. The situation is:
I'm logged in under multiple accounts, but don't have a default user set (I logged out of it, so it was removed from the config). Now when I run ./wf
I get:
You must be authenticated to publish.
Log in first with: wf auth <username>
This is confusing, because I am authenticated -- wf
just doesn't know what account to use, since there's no default and no flags given. So instead, I'd like it to say something like:
You are authenticated, but have no default user set. Supply -user and -host flags.
I started trying to implement this, but it looks like it's going to need a bit more work. It looks like we're getting very close to needing the accounts
command. If that logic is needed to get this error message, then we should do it.
What do you think?
I'll take a look quick, we might be able to get this without adding the accounts command, then add that after. Unless you want it all in for the CLI release.
Let's try to go without it for this initial release and add it later.
ok got it, just going to clean up some redundancy quick
I didn't bother to refactor, it would only save three lines in two places.
Awesome, will test when I'm back at my computer.
Just tested latest changes and now I'm unable to post anything:
$ echo "hi" | ./wf -host team.write.as
Unable to post: Problem creating post: 401. Not logged in.
$ echo "hi" | ./wf -host team.write.as -user matt
Unable to post: Problem creating post: 401. Not logged in.
To be sure, I'm authenticated as matt on team.write.as. Is everything working for you?
Also some odd behavior when I do have a default account:
$ ./wf -host pencil.writefree.ly auth hello
Password: *******
Set hello on pencil.writefree.ly as default account.
$ echo "hi" | ./wf
Error creating data directory: mkdir /home/mattbaer/.writefreely/https:/pencil.writefree.ly: no such file or directory
You must be authenticated to publish.
Log in first with: wf auth <username>
Probably because we store the schema in the configuration. Which is probably correct, e.g. if someone logs in with the --insecure
flag we should respect that. But then when loading the default from the config file, we shouldn't prepend any schema. Could you take a look at that?
Looks really, really good!
I think the very last thing is that we should undo the change where wf
automatically posts to the logged in user's default collection (i.e. the one that matches their username). It's convenient, but it makes publishing drafts impossible, so we should fix that.
I also fixed some weird language when trying to run commands while being unauthenticated.
Sure, I can revert the default collection thing.
Great. Though now I don't seem to be able to post at all:
Unable to post: Problem creating post: 401. Not logged in.
silly question, are you logged in? I tried with both wf
and writeas
with success. using the default command, and new
. which sub command are you using?
Hmm yeah, I authenticated right after I pulled in those changes. But then I re-authenticated with the same exact account and now it's all working. Weird. But draft publishing works :+1:
Doing one last run-through and then we'll merge!
There are still some very small places where we can improve the UX, but we can address them in the next update. Great work! Merging now.
This one is a bit huge.
First this creates a new binary
wf
which supports additional features not needed on write.as. Namely different hosts and multiple users, as many user accounts can be authenticated as you wish. Just pass a-u <username>
global flag to select the one to use for an action. i.e.wf -u rob posts
This would be v1.0 for wf.
ref T592, T593, T594, T595, T597, T634, T635, T645