Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve custom commands interface #2109

Conversation

Mihai22125
Copy link
Contributor

@Mihai22125 Mihai22125 commented Aug 10, 2022

Allow a name to be specified in the prompt so that prompts can be referred by name.

- key : 'N'
    description: 'create annotated tag'
    command: "git tag -a {{ .Form.tagName }} -m \"{{ .Form.tagMessage }}\""
    context: 'tags'
    prompts:
      - type: 'input'
        title: 'Annotated tag name:'
        key: 'tagName'
      - type: 'input'
        title: 'Annotated tag message:'
        key: 'tagMessage'

Referring to prompt responses by index is kept in the code for backwards compatibility.

Add functionality for returning an error if the referred prompt is not defined.

This resolves: #2103

@jesseduffield
Copy link
Owner

Code looks good, could you add an integration test for this? You can use https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/tests/custom_commands/multiple_prompts.go as a reference. Also check out https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md

Lemme know if you need any guidance

@Mihai22125
Copy link
Contributor Author

Hi @jesseduffield, I would be happy to give it a shot.

@Mihai22125 Mihai22125 force-pushed the improve_custom_commands_interface branch from fdbf94f to 6a906c9 Compare August 15, 2022 20:43
{
Key: "a",
Context: "files",
Command: `echo "{{index .Form.FileContent}}" > {{index .Form.FileName}}`,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the index thing here necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like I forgot to remove it. I updated the code now

Add Form field to CustomCommandObjects struct

Write user prompts responses to Form field

Ensure that map keys exists

Add form prompts integration test

Remove redundant index
@jesseduffield jesseduffield force-pushed the improve_custom_commands_interface branch from cf82366 to 7e9dffe Compare September 17, 2022 21:59
@jesseduffield jesseduffield merged commit dcbebef into jesseduffield:master Sep 17, 2022
@jesseduffield
Copy link
Owner

Thanks for waiting for my re-review. Great work!

@Mihai22125
Copy link
Contributor Author

I'm glad that I could contribute to this cool project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better custom commands interface
2 participants