AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.09k stars 352 forks source link

Disable Editor prompt #313

Open shanestarcher-okta opened 3 years ago

shanestarcher-okta commented 3 years ago

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

AlecAivazis commented 3 years ago

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

shanestarcher-okta commented 3 years ago

@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
                }
            }
jaredallard commented 3 years ago

@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

shanestarcher-okta commented 3 years ago

@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 commented 3 years ago

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