miniscruff/changie

Allow using your editor to create body messages

Closed this issue · 9 comments

Is your feature request related to a problem? Please describe.
Complicated and detailed changelogs are hard to do from the console, the users EDITOR is most likely the best method.

Describe the solution you'd like
changie new --editor will go through the normal prompts but when it comes to editing the body you will instead be redirected to your editor.
Similar to a git commit a comment will appear showing the prompts and anything else that will be stripped out when submitting.

Describe alternatives you've considered
Block inputs are good but break down when you get to writing code blocks and the like.

Additional context
Related to #499

wizsk commented

With a little help. I can solve the issue.

@wizsk Sure, one thing I would do is to take a look at the contributing and readme to get started, make sure your environment is all setup.
In terms of the actual work, the idea is to basically get this example from bubbletea ( https://github.com/charmbracelet/bubbletea/blob/master/examples/exec/main.go ) to be used if you added --editor to the changie new option specifically for typing out the body message.
It should still prompt the user for kind and custom values but for the body it should open your editor.

Fundamentally it should work quite similar to git commit where your editor opens and when exiting we use the data in that temp file.

wizsk commented

I have read the contributing and readme.
I looked at the code base.
https://github.com/miniscruff/changie/blob/a202a7a21d49c4f84b486edab2c76d47efd3d622/cmd/new.go#L71C1-L76C3
like this flag. if --editor is provided getEditorInputFunc() should run to get the input right?

Yea that is the idea, not sure how hard it's going to be.

wizsk commented

Ok then just create a temporary file in the tmp dir open the text editor there, read the file and delete the file afterwards.

Should edit handle function should be triggered by this?

	cmd := &cobra.Command{
		Use:   "new",
		Short: "Create a new change file",
		Long: `Creates a new change file.
Change files are processed when batching a new release.
Each version is merged together for the overall project changelog.`,
		Args: cobra.NoArgs,
		RunE: n.Run,
		Run: func(cmd *cobra.Command, args []string) {
			if bodyTxtEditor {
				getEditorInputFunc()
			}
		},
	}

https://github.com/miniscruff/changie/blob/a202a7a21d49c4f84b486edab2c76d47efd3d622/cmd/new.go#L43C1-L51C3
Here creating new cmd.Flags().StringVarP(&bodyTxtEdito, "editor", "e", "edit with an editor")

How will the editor name set?
What will the default editor?

wizsk commented

If everything looks ok can i get assigned?

I don't use the assignees except for myself but feel free to work on it and I will review any pr as quickly as I can.

I don't quite understand your first question unfortunately.
The editor name comes from the EDITOR env var.
Default can be vim.

wizsk commented

i asked where should I get the editor name?

This function here is where we create the prompts for body messages https://github.com/miniscruff/changie/blob/main/core/config.go#L76