writeas / writeas-cli

Command line client for Write.as / WriteFreely
https://write.as/apps/cli
GNU General Public License v3.0
113 stars 20 forks source link

Windows 10 #6

Closed ocnios closed 9 years ago

ocnios commented 9 years ago

I get 'posting...' message in Windows 10 but no post url.

thebaer commented 9 years ago

This seems to be caused by EOF (Ctrl-Z) not getting correctly read on Windows. Full steps to reproduce / conversation here.

Best workaround in the meantime will be piping text to writeas.exe (e.g. cat mypost.txt | writeas.exe), rather than running the program and entering text that way.

ocnios commented 9 years ago

Windows command prompt does not include a 'cat' command so this works, but only when done from the PowerShell.

ocnios commented 9 years ago

A friend of mine came up with a PowerShell script to avoid having to create and save a text file and then pipe said file to writeas. This allows you to compose a post within PowerShell, entering the word 'done' on a line by itself ends the script and sends the post. Change 'done' to something else if you like.

$file = "tmp.txt"
"" > tmp.txt
while ($input = read-host ) {
    if ($input -eq "done") { break }
    $input >> tmp.txt
}
$output = cat $file | writeas
$output.replace('Posting...','') | clip.exe

Save that as something like send-writeas.ps1

This also copies resulting URL to clipboard without the 'Posting...' message, though there is still an empty line above the link that gets copied.

thebaer commented 9 years ago

Very cool! Thanks for bringing this up. I think this is an important use case, so I'm going to add an easy way to create posts with the app that doesn't require piping a file to it.

Also, I think I have Cygwin installed -- oops. So I guess the command prompt equivalent would be type mypost.txt | writeas.exe

ocnios commented 9 years ago

Great job on the updated v3 fixes. Some notes/thoughts. On Windows 10 I created some local posts which I was then unable to delete for some reason. To clear the list of posts in such a case the file that keeps a list of posts is located at: C:\Users\username\AppData\Roaming\Write.as\

Deleting the posts.psv file located here will delete all listed posts.

The recently updated writeas code works great on Windows 10 using notepad but I noticed if Sublime Text is set as the default .txt handler that there is a glitch. Using 'writeas new' will open Sublime Text and upon exiting Sublime Text and entering ctrl+c into the command prompt the post process completes and returns a valid writeas link with the contents of the post, but if you have multiple tabs open in Sublime Text and close just the writeas tab then the post process returns 'Empty post. Bye!'

Great progress but I would like to see either the ability to compost the post directly in the command prompt or the ability to handle a multi tab session with Sublime. The cherry on top would be the post link being auto sent to the clipboard.

thebaer commented 9 years ago

Thanks for the feedback and testing everything. Did any error message show when you tried deleting your posts?

That's a good point about Sublime. For me, it only worked when Sublime wasn't running and I closed the entire app after editing the post, which is still less than ideal. There is always going to be a lot of variance in GUI editors.

So after some research, it looks like the built-in options for editing from the command prompt on Windows are edit (on 32-bit versions of Windows) and copy con, the latter which will be similar to what you were previously trying to do. I'd love to let users override the default editor command like they can on Linux/OS X (by using the EDITOR environment variable), but I'm not familiar with any similar conventions on Windows. Do you know of any?

Also a great point about copying to the clipboard -- that should be fairly trivial to add.

thebaer commented 9 years ago

I just uploaded a new build to the URL I previously sent you. Now writeas new will let you create a post in the command prompt and the URL will automatically get added to the clipboard when you publish a new post. Let me know how that works.

ocnios commented 9 years ago

Here is what I got when trying to delete the local posts: olderrors

Here is what happens with the new build when I 'writeas new': newerrors

When I writeas list even though I get the message '1 file copied' no posts are listed and no url ever gets sent to my clipboard.

I think keeping both methods would be great because I could see use cases for coders, devs, and scripters to compose in something like sublime, and shorter blog like posts via command pompt, especially when the 'claim a handle/username' becomes available.

I'll research a windows convention for EDITOR and let you know what I come up with.

thebaer commented 9 years ago

Ah, I forgot to mention that you'll need to finish/publish the post by pressing Ctrl-Z (or F6) then Enter. What are you pressing right now to signal the end of your post? I'll see if I can add some helpful messaging there.

The 1 file(s) copied output is from the new copy con command. You should actually see the "Posting..." message following it, indicating that it's publishing what you've written -- then you'll see the URL and it'll copy to your clipboard. This is why it isn't showing up when you run writeas list. Once you've published something, writeas list will output a list of post IDs (the part in the URL that comes after https://write.as/), like:

3psnxyhqxy3hq
p2ss6e79etmvh
j9o0dqohqmpqm

If you wanted to delete a post from Write.as, you'd use one of these IDs in your command, e.g. writeas delete 3psnxyhqxy3hq. Since https://write.as/HelloWorld and https://write.as/Goodbye don't exist, you're seeing that error message.

And yes, I'll re-add the option to launch the default GUI editor -- glad you thought it'd be useful, too.

ocnios commented 9 years ago

Thanks! Posting via the command prompt and ending with f6 works great! Posts and copies url beautifully. I'm still running into the following errors with local posts though:

deletelocal

thebaer commented 9 years ago

Excellent!

I see what's happening now though. The writeas add command is there because there's currently no way to access your posts across devices; it's meant for adding pre-existing posts to your posts.psv file, for easier editing later. The primary use case would be if you were using the Android app, you can "View Details" on a post, and use the post ID and "edit token" shown there when doing writeas add. But how were you imagining that command would work?

thebaer commented 9 years ago

I've also added a more helpful help message to the writeas add command with 995d73db. Closing this, now that these changes are in v0.3.