hedgedoc / cli

A tiny CLI for HedgeDoc
GNU Affero General Public License v3.0
150 stars 37 forks source link

Feat: Adds edit command #45

Closed DistroByte closed 3 years ago

pirate commented 3 years ago

I would also add that it should be able to take a note ID as an argument to skip the menu selection step.

DistroByte commented 3 years ago

@davidmehren I had fixed the issue of default editor being vim, it seems to have reverted back to vim, my apologies!

Regarding the temp file, I didn't know that was a tool I could use! I'll make that change too!

DistroByte commented 3 years ago

I would also add that it should be able to take a note ID as an argument to skip the menu selection step.

Yeah that should be no issue to implement, I can do that!

DistroByte commented 3 years ago

I would also add that it should be able to take a note ID as an argument to skip the menu selection step.

Currently I have my first optional parameter be the number of notes to display in the select parameter. If I reverse the list of notes (so the most recent note is 1 on the list, would that suit better? I am not sure how to parse arguments from the cli. I am welcome to other's contributions!

DistroByte commented 3 years ago

One way to work around this that would be very ugly would be to create a second command called edit-id or similar to skip the select table altogether, though that seems slightly pointless.

Also @davidmehren , at least on WSL for me, the EDITOR environment variable is not set. I am using Ubuntu and I ran select-editor to make sure it wasn't nano

DistroByte commented 3 years ago

Have solved the issue of the editor not being set, it seems to make the edit command link to your editor of choice. The next issue I am facing is with the mktemp command. It doesn't seem to let me edit the file at all. I have attached a screenshot to show you

pirate commented 3 years ago

I can push a commit to handle the CLI arg (it's just $1 in bash), no need to create a separate edit-id command.

DistroByte commented 3 years ago

That would replace the ability to change how many of the most recent ids you want to display though. nor sure if that is exactly what is needed

pirate commented 3 years ago

nah we can just use --flags like -l 5 or --limit=5

ErikMichelson commented 3 years ago

I'm sorry, but this won't work.

An import with a given note id (/new/noteid) can not be issued when there's already a note with the given note id. This returns an HTTP 409 response. Besides that importing notes with a given note id is only possible when FreeURL mode is enabled.

Except from the realtime socket communication and manual database manipulations, there is no way to update the contents of a note.

DistroByte commented 3 years ago

I don't see an easy way to make that happen with just plain bash, so in this case, I think it's fair to say this PR can be closed.

You are right, there is no way to edit a note without socket communication. Hopefully v2 will have an easier way to interact over CLI.

Thanks for all your feedback @davidmehren and @pirate <3