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

CLI: use consola.prompt for prompts in all commands #83

Open
Woetfin opened this issue Oct 23, 2023 · 0 comments
Open

CLI: use consola.prompt for prompts in all commands #83

Woetfin opened this issue Oct 23, 2023 · 0 comments
Labels
feature request New feature or request

Comments

@Woetfin
Copy link
Contributor

Woetfin commented Oct 23, 2023

Is your feature request related to a problem? Please describe.
The current prompt system is still pretty raw, while the consola package we're using has a fancier way of asking for prompts.

Describe the solution you'd like
Use the consola.prompt function, an example of this for the import-reconciliation command could look like this:

function requireCommandPromptConfirmation(options, callback) {
  if (!options.yes) {
    cliUtils.promptConfirmation().then((confirmed) => {
      console.log(confirmed);
      if (confirmed === true) {
        callback(options);
      }
    });
  } else {
    callback(options);
  }
}

function importReconciliation(options) {
  cliUtils.checkDefaultFirm(options.firm, firmIdDefault);
  if (options.handle) {
    toolkit.fetchReconciliationByHandle(options.firm, options.handle);
  } else if (options.id) {
    toolkit.fetchReconciliationById(options.firm, options.id);
  } else if (options.all) {
    toolkit.fetchAllReconciliations(options.firm);
  }
}

// READ reconciliations
program
  .command("import-reconciliation")
  .description("Import reconciliation templates")
  .requiredOption(
    "-f, --firm <firm-id>",
    "Specify the firm to be used",
    firmIdDefault
  )
  .option("-h, --handle <handle>", "Import a specific reconciliation by handle")
  .option("-i, --id <id>", "Import a specific reconciliation by id")
  .option("-a, --all", "Import all reconciliations")
  .option("--yes", "Skip the prompt confirmation (optional)")
  .action((options) => {
    cliUtils.checkUniqueOption(["handle", "id", "all"], options);
    requireCommandPromptConfirmation(options, importReconciliation);
  });

Describe alternatives you've considered
Keep using the standard prompts

Additional context
FR noted down and discussed with @AgustinSilverfin during review of #59; decided to move this to a separate issue since we decided to leave it out of the scope of the initial PR.

@Woetfin Woetfin added the feature request New feature or request label Oct 23, 2023
@Woetfin Woetfin mentioned this issue Oct 23, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant