survey icon indicating copy to clipboard operation
survey copied to clipboard

Disable Editor prompt

Open shanestarcher-okta opened this issue 4 years ago • 5 comments

I would like to disable the editor prompt. This does not currently seem to be available is that correct?

shanestarcher-okta avatar Nov 17 '20 21:11 shanestarcher-okta

hey @shanestarcher-okta! I guess i'm a little confused what you mean, is disabling the prompt different from just not including it? If you are looking for a way to optionally skip some questions based on reponse values, we recommend handling it with multiple calls to survey.Ask or survey.AskOne.

Please let me know if this doesn't cover your usecase

AlecAivazis avatar Nov 18 '20 19:11 AlecAivazis

@AlecAivazis the goal is during a cli to not prompt the user at all, but to drop directly into the edit mode.

So in this case I don't actually ever want to ask anything. I would prefer this just drop directly into a edit mode and not ask if the user wants to edit. We have a flag -i that puts it into interactive mode.

			if interactive {
				prompt := &survey.Editor{
					FileName:      "*.md",
					Message:       "Would you like to make any changes",
					AppendDefault: true,
					HideDefault:   true,
					Default:       str,
				}
				err := survey.AskOne(prompt, &str)
				if err != nil {
					return err
				}
			}

shanestarcher-okta avatar Nov 18 '20 20:11 shanestarcher-okta

@shanestarcher-okta Wouldn't it make more sense to not call the survey at all then? Seems like calling $EDITOR yourself is more preferable here

jaredallard avatar Dec 01 '20 07:12 jaredallard

@jaredallard I could certainly do that, but as far as I know, it seems to fit into the concept of the survey. Which is giving the user interactive input and it's 99% already supported.

shanestarcher-okta avatar Dec 01 '20 11:12 shanestarcher-okta

And I would essentially need to know caveats like this that Survey has already found - https://github.com/AlecAivazis/survey/blob/34c84b521b1ede46d3297a274a7104538c49f1e4/editor.go#L158

shanestarcher-okta avatar Dec 01 '20 11:12 shanestarcher-okta