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

[Request] disable flag for confirm #244

Open
tylersayshi opened this issue Mar 5, 2025 · 2 comments
Open

[Request] disable flag for confirm #244

tylersayshi opened this issue Mar 5, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@tylersayshi
Copy link

tylersayshi commented Mar 5, 2025

Is your feature request related to a problem? Please describe.

when using p.group I want to first ask for a folder name, then check if that folder exists, then confirm the user wants to overwrite the folder when it exists. If the folder does not yet exist, the confirm step should be skipped.

Describe the solution you'd like

a disable flag like this:

const results = await p.group({
  folder: () =>
    p.text({
      message: "Folder name",
    }),
  overwrites: ({ results }) =>
    p.confirm({
      message: `would you like to overwrite ${results.folder}?`,
      disable: !folderExists(results.folder),
    }),
});

Describe alternatives you've considered

Alternatively I can split into two groups, check in between each group and manually handle the cancel.

e.g.: https://github.com/dai-shi/waku/pull/1290/files

This is ok, but less nice. Maybe there is a better way to do what I am doing here altogether though... that would be nice.

Additional context

happy to help with a PR if this is an acceptable thing to add.

@tylersayshi tylersayshi added the enhancement New feature or request label Mar 5, 2025
@github-project-automation github-project-automation bot moved this to Needs triage in Triage Board Mar 5, 2025
@MacFJA
Copy link

MacFJA commented Mar 14, 2025

What you can also do, is not use a confirm is the folder don't exist:

const results = await p.group({
  folder: () =>
    p.text({
      message: "Folder name",
    }),
  overwrites: ({ results }) => {
    if (!folderExists(results.folder)) {
      p.log.step('New folder, nothing to overwrite');
      return Promise.resolve(false);
    }
    return p.confirm({
      message: `would you like to overwrite ${results.folder}?`,
    }),
  }
});

@tylersayshi
Copy link
Author

What you can also do, is not use a confirm is the folder don't exist:

This is really nice! Thank you @MacFJA!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Needs triage
Development

No branches or pull requests

2 participants