@fnndsc/chili 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ import { feeds_searchByTerm, feed_deleteById } from "../commands/feeds/delete.js
9
9
  import { prompt_confirm } from "../utils/ui.js";
10
10
  import { feed_create as feed_create_command } from "../commands/feed/create.js"; // Original name
11
11
  import { feedCreate_render } from "../views/feed.js"; // Still needed for feedCreate_render
12
+ import { chiliErrLog, chiliLog } from "../screen/output.js";
12
13
  // import { FeedListResult } from "../commands/feeds/list.js"; // No longer needed
13
14
  /**
14
15
  * Handles commands related to groups of ChRIS feeds.
@@ -25,10 +26,10 @@ export class FeedGroupHandler {
25
26
  // async feeds_list(options: CLIoptions): Promise<void> {
26
27
  // try {
27
28
  // const { feeds, selectedFields }: FeedListResult = await feeds_fetchList(options);
28
- // console.log(feedList_render(feeds, selectedFields, { table: options.table, csv: options.csv }));
29
+ // chiliLog(feedList_render(feeds, selectedFields, { table: options.table, csv: options.csv }));
29
30
  // } catch (error: unknown) {
30
31
  // const msg = error instanceof Error ? error.message : String(error);
31
- // console.error(chalk.red(`Error listing feeds: ${msg}`));
32
+ // chiliErrLog(chalk.red(`Error listing feeds: ${msg}`));
32
33
  // }
33
34
  // }
34
35
  /**
@@ -41,11 +42,11 @@ export class FeedGroupHandler {
41
42
  table_display(fields, ["fields"]);
42
43
  }
43
44
  else {
44
- console.log(`No resource fields found for ${this.assetName}.`);
45
+ chiliLog(`No resource fields found for ${this.assetName}.`);
45
46
  }
46
47
  }
47
48
  catch (error) {
48
- console.log(errorStack.stack_search(this.assetName)[0]);
49
+ chiliLog(errorStack.stack_search(this.assetName)[0]);
49
50
  }
50
51
  }
51
52
  /**
@@ -59,18 +60,18 @@ export class FeedGroupHandler {
59
60
  for (const searchPart of searchParts) {
60
61
  const feedIds = await this.baseGroupHandler.IDs_getFromSearch({ search: searchPart });
61
62
  if (!feedIds || feedIds.length === 0) {
62
- console.log(`No feeds found matching: ${searchPart}`);
63
+ chiliLog(`No feeds found matching: ${searchPart}`);
63
64
  continue;
64
65
  }
65
66
  for (const feedId of feedIds) {
66
- console.log(`Sharing feed ID: ${feedId}...`);
67
+ chiliLog(`Sharing feed ID: ${feedId}...`);
67
68
  const shareOptions = { is_public: options.is_public === true };
68
69
  const success = await feed_shareById(Number(feedId), shareOptions);
69
70
  if (success) {
70
- console.log(`Feed ID ${feedId} shared successfully.`);
71
+ chiliLog(`Feed ID ${feedId} shared successfully.`);
71
72
  }
72
73
  else {
73
- console.error(`Failed to share feed ID ${feedId}.`);
74
+ chiliErrLog(`Failed to share feed ID ${feedId}.`);
74
75
  }
75
76
  }
76
77
  }
@@ -85,11 +86,11 @@ export class FeedGroupHandler {
85
86
  for (const searchPart of searchParts) {
86
87
  const items = await feeds_searchByTerm(searchPart);
87
88
  if (items.length === 0) {
88
- console.log(`No feeds found matching: ${searchPart}`);
89
+ chiliLog(`No feeds found matching: ${searchPart}`);
89
90
  continue;
90
91
  }
91
92
  for (const item of items) {
92
- console.log(`Preparing to delete Feed: ID=${item.id}, Name=${item.name}`);
93
+ chiliLog(`Preparing to delete Feed: ID=${item.id}, Name=${item.name}`);
93
94
  if (!options.force) {
94
95
  const confirmed = await prompt_confirm(`Are you sure you want to delete feed ${item.name} (ID: ${item.id})?`);
95
96
  if (!confirmed)
@@ -98,10 +99,10 @@ export class FeedGroupHandler {
98
99
  const id = typeof item.id === "number" ? item.id : Number(item.id);
99
100
  const success = await feed_deleteById(id);
100
101
  if (success) {
101
- console.log(`Deleted feed ${item.id}`);
102
+ chiliLog(`Deleted feed ${item.id}`);
102
103
  }
103
104
  else {
104
- console.error(`Failed to delete feed ${item.id}`);
105
+ chiliErrLog(`Failed to delete feed ${item.id}`);
105
106
  }
106
107
  }
107
108
  }
@@ -160,20 +161,20 @@ export class FeedMemberHandler {
160
161
  try {
161
162
  const feed = await feed_create_command(options);
162
163
  if (feed) {
163
- console.log(feedCreate_render(feed));
164
+ chiliLog(feedCreate_render(feed));
164
165
  return feed;
165
166
  }
166
- console.error(chalk.red("Feed creation returned null result."));
167
+ chiliErrLog(chalk.red("Feed creation returned null result."));
167
168
  const errors = errorStack.allOfType_get('error'); // Keep error reporting
168
169
  if (errors.length > 0) {
169
- console.error(chalk.red('Errors:'));
170
- errors.forEach(e => console.error(chalk.red(` - ${e}`)));
170
+ chiliErrLog(chalk.red('Errors:'));
171
+ errors.forEach(e => chiliErrLog(chalk.red(` - ${e}`)));
171
172
  }
172
173
  return null;
173
174
  }
174
175
  catch (error) {
175
176
  const message = error instanceof Error ? error.message : String(error);
176
- console.error(chalk.red(`Error: ${message}`));
177
+ chiliErrLog(chalk.red(`Error: ${message}`));
177
178
  return null;
178
179
  }
179
180
  }
@@ -197,7 +198,7 @@ export class FeedMemberHandler {
197
198
  });
198
199
  }
199
200
  else {
200
- console.error(`Failed to find '${this.assetName}' command. The 'new' subcommand was not added.`);
201
+ chiliErrLog(`Failed to find '${this.assetName}' command. The 'new' subcommand was not added.`);
201
202
  }
202
203
  }
203
204
  }
@@ -12,6 +12,7 @@ import { files_searchByTerm, files_deleteById } from "../commands/files/delete.j
12
12
  import { prompt_confirm } from "../utils/ui.js";
13
13
  import { files_viewContent } from "../commands/file/view.js";
14
14
  import { fileList_render } from "../views/file.js";
15
+ import { chiliErrLog, chiliLog } from "../screen/output.js";
15
16
  /**
16
17
  * Handles commands related to groups of ChRIS files, links, or directories.
17
18
  */
@@ -49,33 +50,33 @@ export class FileGroupHandler {
49
50
  try {
50
51
  const results = await files_fetchList(options, this.assetName, path);
51
52
  if (!results) {
52
- console.error(`No ${this.assetName} resources found. Perhaps check your current context?`);
53
+ chiliErrLog(`No ${this.assetName} resources found. Perhaps check your current context?`);
53
54
  return;
54
55
  }
55
56
  if (results.tableData.length === 0) {
56
- console.log(`No ${this.assetName} found matching the criteria.`);
57
+ chiliLog(`No ${this.assetName} found matching the criteria.`);
57
58
  }
58
59
  else {
59
60
  const uniqueResults = resourceColumns_removeDuplicates(results);
60
61
  // cumin returns dynamic table rows (Record<string, unknown>[]);
61
62
  // narrow to the FileResource view model at this boundary.
62
- console.log(fileList_render(uniqueResults.tableData, uniqueResults.selectedFields, { table: options.table, csv: options.csv }));
63
+ chiliLog(fileList_render(uniqueResults.tableData, uniqueResults.selectedFields, { table: options.table, csv: options.csv }));
63
64
  }
64
65
  }
65
66
  catch (error) {
66
67
  const errors = errorStack.stack_search(this.assetName);
67
68
  if (errors.length > 0) {
68
- console.log(errors[0]);
69
+ chiliLog(errors[0]);
69
70
  }
70
71
  else {
71
72
  const msg = error instanceof Error ? error.message : String(error);
72
- console.error(`Error: ${msg}`);
73
+ chiliErrLog(`Error: ${msg}`);
73
74
  const errObj = error;
74
75
  if (msg.includes("Internal server error") || (errObj && errObj.response && errObj.response.status === 500)) {
75
- console.error(chalk.yellow("\nHint: This indicates a problem on the ChRIS server (CUBE)."));
76
- console.error(chalk.yellow(" Please contact your system administrator or check the CUBE logs."));
77
- console.error(chalk.yellow(" To see full debug output, run the command again with CHILI_DEBUG=true:"));
78
- console.error(chalk.yellow(" CHILI_DEBUG=true chili ..."));
76
+ chiliErrLog(chalk.yellow("\nHint: This indicates a problem on the ChRIS server (CUBE)."));
77
+ chiliErrLog(chalk.yellow(" Please contact your system administrator or check the CUBE logs."));
78
+ chiliErrLog(chalk.yellow(" To see full debug output, run the command again with CHILI_DEBUG=true:"));
79
+ chiliErrLog(chalk.yellow(" CHILI_DEBUG=true chili ..."));
79
80
  }
80
81
  }
81
82
  }
@@ -90,11 +91,11 @@ export class FileGroupHandler {
90
91
  table_display(fields, ["fields"]);
91
92
  }
92
93
  else {
93
- console.log(`No resource fields found for ${this.assetName}.`);
94
+ chiliLog(`No resource fields found for ${this.assetName}.`);
94
95
  }
95
96
  }
96
97
  catch (error) {
97
- console.log(errorStack.stack_search(this.assetName)[0]);
98
+ chiliLog(errorStack.stack_search(this.assetName)[0]);
98
99
  }
99
100
  }
100
101
  /**
@@ -105,16 +106,16 @@ export class FileGroupHandler {
105
106
  for (const searchPart of searchParts) {
106
107
  const items = await files_searchByTerm(searchPart, this.assetName);
107
108
  if (items.length === 0) {
108
- console.log(`No ${this.assetName} found matching: ${searchPart}`);
109
+ chiliLog(`No ${this.assetName} found matching: ${searchPart}`);
109
110
  continue;
110
111
  }
111
112
  for (const item of items) {
112
113
  const displayName = item.fname || item.path || item.id;
113
114
  if (!item.id) {
114
- console.error(`Cannot delete item without ID. Details: ${JSON.stringify(item)}`);
115
+ chiliErrLog(`Cannot delete item without ID. Details: ${JSON.stringify(item)}`);
115
116
  continue;
116
117
  }
117
- console.log(`Preparing to delete ${this.assetName}: ID=${item.id}, Name=${displayName}`);
118
+ chiliLog(`Preparing to delete ${this.assetName}: ID=${item.id}, Name=${displayName}`);
118
119
  if (!options.force) {
119
120
  const confirmed = await prompt_confirm(`Are you sure you want to delete ${this.assetName} ${displayName} (ID: ${item.id})?`);
120
121
  if (!confirmed)
@@ -122,10 +123,10 @@ export class FileGroupHandler {
122
123
  }
123
124
  const success = await files_deleteById(item.id, this.assetName);
124
125
  if (success) {
125
- console.log(`Deleted ${this.assetName} ${item.id}`);
126
+ chiliLog(`Deleted ${this.assetName} ${item.id}`);
126
127
  }
127
128
  else {
128
- console.error(`Failed to delete ${this.assetName} ${item.id}`);
129
+ chiliErrLog(`Failed to delete ${this.assetName} ${item.id}`);
129
130
  }
130
131
  }
131
132
  }
@@ -137,18 +138,18 @@ export class FileGroupHandler {
137
138
  */
138
139
  async files_share(options) {
139
140
  try {
140
- console.log(`Sharing ${this.assetName} from ${this.controller.path_get}...`);
141
+ chiliLog(`Sharing ${this.assetName} from ${this.controller.path_get}...`);
141
142
  if (options.force) {
142
- console.log("Force sharing enabled");
143
+ chiliLog("Force sharing enabled");
143
144
  }
144
145
  await this.controller.files_share(options);
145
146
  }
146
147
  catch (error) {
147
148
  if (error instanceof Error) {
148
- console.error(`Error sharing ${this.assetName}: ${error.message}`);
149
+ chiliErrLog(`Error sharing ${this.assetName}: ${error.message}`);
149
150
  }
150
151
  else {
151
- console.error(`An unknown error occurred while sharing the ${this.assetName}`);
152
+ chiliErrLog(`An unknown error occurred while sharing the ${this.assetName}`);
152
153
  }
153
154
  }
154
155
  }
@@ -233,14 +234,14 @@ export class FileMemberHandler {
233
234
  const success = await files_create(fileIdentifier, options);
234
235
  if (success) {
235
236
  const resolvedChRISPath = await path_resolveChrisFs(fileIdentifier, options);
236
- console.log(`File created successfully at: ${resolvedChRISPath}`);
237
+ chiliLog(`File created successfully at: ${resolvedChRISPath}`);
237
238
  }
238
239
  // If success is false, files_create would have thrown an error which is caught below.
239
240
  }
240
241
  catch (error) {
241
242
  // Log the error from files_create
242
243
  const message = error instanceof Error ? error.message : String(error);
243
- console.error(message);
244
+ chiliErrLog(message);
244
245
  }
245
246
  }
246
247
  /**
@@ -274,7 +275,7 @@ export class FileMemberHandler {
274
275
  .action(async (options) => {
275
276
  await this.file_cat(options);
276
277
  });
277
- console.log("FileMemberHandler commands set up successfully");
278
+ chiliLog("FileMemberHandler commands set up successfully");
278
279
  }
279
280
  /**
280
281
  * Displays the content of the file.
@@ -284,18 +285,18 @@ export class FileMemberHandler {
284
285
  async file_cat(options) {
285
286
  try {
286
287
  const path = this.controller.path_get;
287
- console.log(`Viewing file at ${path}`);
288
+ chiliLog(`Viewing file at ${path}`);
288
289
  const content = await files_viewContent(path);
289
290
  if (content !== null) {
290
- console.log(content);
291
+ chiliLog(content);
291
292
  }
292
293
  else {
293
- console.error("Failed to view file content (empty or error).");
294
+ chiliErrLog("Failed to view file content (empty or error).");
294
295
  }
295
296
  }
296
297
  catch (error) {
297
298
  const message = error instanceof Error ? error.message : String(error);
298
- console.error(`Error viewing file: ${message}`);
299
+ chiliErrLog(`Error viewing file: ${message}`);
299
300
  }
300
301
  }
301
302
  }
@@ -4,6 +4,8 @@
4
4
  * @module
5
5
  */
6
6
  import { ChRISinode_create, listParams_fromOptions, BrowserType, } from "@fnndsc/cumin";
7
+ import { table_render } from "../screen/screen.js";
8
+ import { chiliErrLog, chiliLog } from "../screen/output.js";
7
9
  /**
8
10
  * Lists resources for a given inode path.
9
11
  *
@@ -13,7 +15,7 @@ import { ChRISinode_create, listParams_fromOptions, BrowserType, } from "@fnndsc
13
15
  async function inodeResources_list(path, options) {
14
16
  const chrisInode = await ChRISinode_create(path);
15
17
  if (!chrisInode) {
16
- console.error(`Could not find path '${path}' in the CUBE filesystem.`);
18
+ chiliErrLog(`Could not find path '${path}' in the CUBE filesystem.`);
17
19
  return;
18
20
  }
19
21
  const params = listParams_fromOptions({
@@ -33,28 +35,28 @@ async function inodeResources_list(path, options) {
33
35
  for (const browserType of browserTypes) {
34
36
  const browser = chrisInode.browser_get(browserType);
35
37
  if (!browser) {
36
- console.error(`WARNING: ${browserType} browser is not available`);
38
+ chiliErrLog(`WARNING: ${browserType} browser is not available`);
37
39
  continue;
38
40
  }
39
41
  try {
40
42
  const resourceGet = browser.resource_get;
41
43
  if (!resourceGet) {
42
- console.error(`WARNING: ${browserType} resource is null`);
44
+ chiliErrLog(`WARNING: ${browserType} resource is null`);
43
45
  continue;
44
46
  }
45
47
  const resourcesList = await resourceGet.resources_getList(params);
46
48
  const resourceFields = await resourceGet.resourceFields_get(resourcesList, fieldOptions[browserType]);
47
49
  const results = resourceGet.resources_filterByFields(resourceFields);
48
50
  if (results) {
49
- console.log(`${browserType} resources:`);
50
- console.table(results.tableData, results.selectedFields);
51
+ chiliLog(`${browserType} resources:`);
52
+ chiliLog(table_render(results.tableData, results.selectedFields));
51
53
  }
52
54
  else {
53
- console.error(`${browserType} resources: not found or could not be filtered`);
55
+ chiliErrLog(`${browserType} resources: not found or could not be filtered`);
54
56
  }
55
57
  }
56
58
  catch (error) {
57
- console.error(`${browserType} resources: not found`);
59
+ chiliErrLog(`${browserType} resources: not found`);
58
60
  }
59
61
  }
60
62
  }
@@ -67,12 +69,12 @@ async function inodeResources_list(path, options) {
67
69
  */
68
70
  function inodeFields_list(inodeType, dataObj) {
69
71
  if (!dataObj) {
70
- console.log("No " + inodeType + " at this path");
72
+ chiliLog("No " + inodeType + " at this path");
71
73
  return false;
72
74
  }
73
75
  if (dataObj.fields) {
74
- console.log(inodeType);
75
- console.table(dataObj.fields);
76
+ chiliLog(inodeType);
77
+ chiliLog(table_render(dataObj.fields, ["fields"]));
76
78
  return true;
77
79
  }
78
80
  return false;
@@ -85,7 +87,7 @@ function inodeFields_list(inodeType, dataObj) {
85
87
  async function inodeResourceFields_list(path = "") {
86
88
  const chrisFiles = await ChRISinode_create(path);
87
89
  if (!chrisFiles) {
88
- console.error(`Could not create ChRISinode for path: ${path}`);
90
+ chiliErrLog(`Could not create ChRISinode for path: ${path}`);
89
91
  return;
90
92
  }
91
93
  const fileBrowser = chrisFiles.fileBrowser_get;
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { Command } from "commander";
7
7
  import { FileGroupHandler, FileMemberHandler } from "./fileGroupHandler.js";
8
+ import { chiliErrLog } from "../screen/output.js";
8
9
  /**
9
10
  * Sets up the 'inode' command for interacting with ChRIS filesystem resources.
10
11
  *
@@ -30,7 +31,7 @@ export async function inodeCommand_setup(program) {
30
31
  await fileProgram.parseAsync(args);
31
32
  }
32
33
  else {
33
- console.error("Usage: chili inode <path> <files|file> [options]");
34
+ chiliErrLog("Usage: chili inode <path> <files|file> [options]");
34
35
  command.help();
35
36
  }
36
37
  });
@@ -9,6 +9,7 @@ import { options_toParams } from "../utils/cli.js";
9
9
  import { resourceColumns_removeDuplicates } from "../utils/resourceData.js";
10
10
  import { table_display, table_render, border_draw } from "../screen/screen.js";
11
11
  import * as readline from "readline";
12
+ import { chiliErrLog, chiliLog } from "../screen/output.js";
12
13
  /**
13
14
  * Base handler for groups of ChRIS resources.
14
15
  * Provides common functionality for listing and deleting resources.
@@ -51,11 +52,11 @@ export class BaseGroupHandler {
51
52
  const params = options_toParams(options);
52
53
  const results = await this.chrisObject.asset.resources_listAndFilterByOptions(params);
53
54
  if (!results) {
54
- console.error(`No ${this.assetName} resources found. Perhaps check your current context?`);
55
+ chiliErrLog(`No ${this.assetName} resources found. Perhaps check your current context?`);
55
56
  return;
56
57
  }
57
58
  if (results.tableData.length === 0) {
58
- console.log(`No ${this.assetName} found matching the criteria.`);
59
+ chiliLog(`No ${this.assetName} found matching the criteria.`);
59
60
  }
60
61
  else {
61
62
  const uniqueResults = resourceColumns_removeDuplicates(results);
@@ -73,7 +74,7 @@ export class BaseGroupHandler {
73
74
  return `"${String(val !== undefined ? val : '').split('"').join('""')}"`;
74
75
  }).join(',');
75
76
  }).join('\n');
76
- console.log(header + '\n' + rows);
77
+ chiliLog(header + '\n' + rows);
77
78
  }
78
79
  else if (options.table) {
79
80
  // Explicit Table format (with borders and title)
@@ -104,7 +105,7 @@ export class BaseGroupHandler {
104
105
  }
105
106
  }
106
107
  catch (error) {
107
- console.log(errorStack.stack_search(this.assetName)[0]);
108
+ chiliLog(errorStack.stack_search(this.assetName)[0]);
108
109
  }
109
110
  }
110
111
  /**
@@ -114,18 +115,18 @@ export class BaseGroupHandler {
114
115
  try {
115
116
  const results = await this.chrisObject.asset.resourceFields_get();
116
117
  if (!results) {
117
- console.error(`An error occurred while fetching resource fields for ${this.assetName}.`);
118
+ chiliErrLog(`An error occurred while fetching resource fields for ${this.assetName}.`);
118
119
  return;
119
120
  }
120
121
  if (results.fields.length === 0) {
121
- console.log(`No resource fields found for ${this.assetName}.`);
122
+ chiliLog(`No resource fields found for ${this.assetName}.`);
122
123
  }
123
124
  else {
124
125
  table_display(results.fields, ["fields"]);
125
126
  }
126
127
  }
127
128
  catch (error) {
128
- console.log(errorStack.stack_search(this.assetName)[0]);
129
+ chiliLog(errorStack.stack_search(this.assetName)[0]);
129
130
  }
130
131
  }
131
132
  /**
@@ -243,7 +244,7 @@ export class BaseGroupHandler {
243
244
  const searchResults = await this.chrisObject.asset.resources_listAndFilterByOptions({
244
245
  id: id,
245
246
  });
246
- console.log(border_draw(`checking ${this.assetName} id ${id} ... ${this.msg_OKorNot(searchResults)}`));
247
+ chiliLog(border_draw(`checking ${this.assetName} id ${id} ... ${this.msg_OKorNot(searchResults)}`));
247
248
  if (!force) {
248
249
  confirm = await this.user_confirmContinuation(id, "delete");
249
250
  if (!confirm) {
@@ -254,7 +255,7 @@ export class BaseGroupHandler {
254
255
  border_draw(`deleting ${this.assetName} id ${id} ... ${this.msg_OKorNot(true)}`);
255
256
  }
256
257
  catch (error) {
257
- console.error(`${error}`);
258
+ chiliErrLog(`${error}`);
258
259
  return false;
259
260
  }
260
261
  }
@@ -284,7 +285,7 @@ export class BaseGroupHandler {
284
285
  let nIDs;
285
286
  nIDs = await this.IDs_getFromSearch(options);
286
287
  if (!nIDs) {
287
- console.error(`No ${this.assetName} matched the search criteria.`);
288
+ chiliErrLog(`No ${this.assetName} matched the search criteria.`);
288
289
  return;
289
290
  }
290
291
  if (nIDs) {
@@ -334,7 +335,7 @@ export class BaseGroupHandler {
334
335
  .option("-f, --force", `force the deletion without prompting for user confirmation`)
335
336
  .action(async (searchable, options) => {
336
337
  const searchParts = searchable.split("++").map((part) => part.trim());
337
- // console.log(`searchParts = ${searchParts}`);
338
+ // chiliLog(`searchParts = ${searchParts}`);
338
339
  for (const searchPart of searchParts) {
339
340
  const currentOptions = {
340
341
  ...options,
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import omelette from "omelette";
13
13
  import { run } from "./run.js";
14
+ import { chiliErrLog, chiliLog } from "./screen/output.js";
14
15
  /**
15
16
  * Sets up shell command completion for the standalone chili CLI using omelette.
16
17
  * This is a bin-only concern; in-process hosts provide their own completion.
@@ -50,7 +51,7 @@ function commandCompletion_setup() {
50
51
  },
51
52
  });
52
53
  completion.on("man.doc", ({ reply }) => {
53
- console.log("Autocomplete triggered for man doc command");
54
+ chiliLog("Autocomplete triggered for man doc command");
54
55
  reply([]);
55
56
  });
56
57
  completion.init();
@@ -66,7 +67,7 @@ async function main() {
66
67
  await run(process.argv.slice(2));
67
68
  }
68
69
  main().catch((error) => {
69
- console.error("An error occurred:", error);
70
+ chiliErrLog("An error occurred:", error);
70
71
  process.exit(1);
71
72
  });
72
73
  // Re-export library utilities for consumers that import the package root.
package/dist/lfs/lfs.js CHANGED
@@ -8,6 +8,8 @@
8
8
  */
9
9
  import * as fs from 'fs';
10
10
  import * as path from 'path';
11
+ import { table_render } from "../screen/screen.js";
12
+ import { chiliErrLog, chiliLog } from "../screen/output.js";
11
13
  /**
12
14
  * Lists the contents of a directory with details.
13
15
  *
@@ -22,10 +24,10 @@ export async function dirContents_list(filepath) {
22
24
  return { filename: file, "size(KB)": size, created_at: birthtime };
23
25
  });
24
26
  const detailedFiles = await Promise.all(detailedFilesPromises);
25
- console.table(detailedFiles);
27
+ chiliLog(table_render(detailedFiles, ["filename", "size(KB)", "created_at"]));
26
28
  }
27
29
  catch (error) {
28
- console.error("Error occurred while reading the directory!", error);
30
+ chiliErrLog("Error occurred while reading the directory!", error);
29
31
  }
30
32
  }
31
33
  /**
@@ -36,7 +38,7 @@ export async function dirContents_list(filepath) {
36
38
  export function dir_create(filepath) {
37
39
  if (!fs.existsSync(filepath)) {
38
40
  fs.mkdirSync(filepath);
39
- console.log("The directory has been created successfully");
41
+ chiliLog("The directory has been created successfully");
40
42
  }
41
43
  }
42
44
  /**
@@ -46,7 +48,7 @@ export function dir_create(filepath) {
46
48
  */
47
49
  export function file_create(filepath) {
48
50
  fs.openSync(filepath, "w");
49
- console.log("An empty file has been created");
51
+ chiliLog("An empty file has been created");
50
52
  }
51
53
  /**
52
54
  * Sets up the 'lfs' command group in Commander.
package/dist/man/man.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { topics_list } from "../commands/man/topics.js";
2
2
  import { manPage_display } from "../commands/man/doc.js";
3
+ import { chiliLog } from "../screen/output.js";
3
4
  /**
4
5
  * Sets up the 'man' command for displaying ChILI manual and help pages.
5
6
  *
@@ -24,8 +25,8 @@ export function manCommand_setup(program) {
24
25
  .description("List the available manual page topics")
25
26
  .action(async () => {
26
27
  const files = await topics_list();
27
- console.log("\n\nThe following topics are available:");
28
- console.log("(read more with 'chili man doc <topic>')\n");
29
- console.log(files.join("\n"));
28
+ chiliLog("\n\nThe following topics are available:");
29
+ chiliLog("(read more with 'chili man doc <topic>')\n");
30
+ chiliLog(files.join("\n"));
30
31
  });
31
32
  }
@@ -9,6 +9,7 @@ import chalk from "chalk";
9
9
  import { convert as adoc_convert } from "asciidoctor";
10
10
  import { exec } from "child_process";
11
11
  import os from "os";
12
+ import { chiliErrLog } from "../screen/output.js";
12
13
  const headingStyles = [
13
14
  { regex: /<h1.*?>(.*?)<\/h1>/g, font: "Standard", color: chalk.magenta },
14
15
  { regex: /<h2.*?>(.*?)<\/h2>/g, font: "Slant", color: chalk.yellow },
@@ -175,11 +176,11 @@ export async function browser_open(filePath) {
175
176
  : "xdg-open";
176
177
  exec(`${command} ${tempHtmlPath}`, (error) => {
177
178
  if (error) {
178
- console.error("Error opening browser:", error);
179
+ chiliErrLog("Error opening browser:", error);
179
180
  }
180
181
  });
181
182
  }
182
183
  catch (error) {
183
- console.error("Error opening documentation in browser:", error instanceof Error ? error.message : String(error));
184
+ chiliErrLog("Error opening documentation in browser:", error instanceof Error ? error.message : String(error));
184
185
  }
185
186
  }