Skip to content

Commit

Permalink
Implement consola
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinSilverfin committed Oct 26, 2023
1 parent 2839b87 commit 2e7bd41
Show file tree
Hide file tree
Showing 20 changed files with 250 additions and 189 deletions.
24 changes: 14 additions & 10 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ const devMode = require("../lib/cli/devMode");
const { firmCredentials } = require("../lib/api/firmCredentials");
const SF = require("../lib/api/sfApi");
const path = require("path");
const { consola } = require("consola");

let firmIdDefault = cliUtils.loadDefaultFirmId();
cliUtils.handleUncaughtErrors();

// Name & Version
program.name("silverfin");
if (pkg.version) {
program.version(pkg.version);
}
pkg.version ? program.version(pkg.version) : undefined;
// Verbose Option
program.option("-v, --verbose", "Verbose output");
program.on("option:verbose", () => {
consola.level = "debug"; // default: "info"
});

// READ reconciliations
program
Expand Down Expand Up @@ -459,7 +463,7 @@ program
);
} else {
if (options.previewOnly && !options.htmlInput && !options.htmlPreview) {
console.log(
consola.info(
`When using "--preview-only" you need to specify at least one of the following options: "--html-input", "--html-preview"`
);
process.exit(1);
Expand Down Expand Up @@ -545,22 +549,22 @@ program
if (options.setFirm) {
firmCredentials.setDefaultFirmId(options.setFirm);
const currentDirectory = path.basename(process.cwd());
console.log(`${currentDirectory}: firm id set to ${options.setFirm}`);
consola.success(`${currentDirectory}: firm id set to ${options.setFirm}`);
}
if (options.getFirm) {
const storedFirmId = firmCredentials.getDefaultFirmId();
if (storedFirmId) {
console.log(`Firm id previously stored: ${storedFirmId}`);
consola.info(`Firm id previously stored: ${storedFirmId}`);
} else {
console.log("There is no firm id previously stored");
consola.info("There is no firm id previously stored");
}
}
if (options.listAll) {
const firms = firmCredentials.listAuthorizedFirms() || [];
if (firms) {
console.log("List of authorized firms");
consola.info("List of authorized firms");
firms.forEach((element) =>
console.log(`- ${element[0]}${element[1] ? ` (${element[1]})` : ""}`)
consola.log(`- ${element[0]}${element[1] ? ` (${element[1]})` : ""}`)
);
}
}
Expand Down Expand Up @@ -710,5 +714,5 @@ if (pkg.repository && pkg.repository.url) {
(async function () {
// Check if there is a new version available
await cliUpdates.checkVersions();
program.parse();
await program.parseAsync();
})();
Loading

0 comments on commit 2e7bd41

Please sign in to comment.