1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! Config command implementations for Node.js bindings.
//!
//! # What
//!
//! This module implements the config NAPI functions (`configShow`, `configValidate`)
//! that allow users to inspect and validate their workspace configuration.
//!
//! # How
//!
//! The module provides two functions:
//!
//! - `configShow`: Displays the current workspace configuration
//! - `configValidate`: Validates the configuration and reports any issues
//!
//! Each function:
//! 1. Validates the input parameters (root path)
//! 2. Calls the appropriate `execute_*` function from `sublime_cli_tools`
//! 3. Captures the JSON output
//! 4. Returns a `JsonResponse<T>` with the result
//!
//! # Why
//!
//! Configuration management is essential for understanding and troubleshooting
//! workspace settings. These commands help users verify their setup and identify
//! any configuration issues.
//!
//! # Examples
//!
//! ```typescript
//! import { configShow, configValidate } from '@websublime/workspace-tools';
//!
//! // Show current configuration
//! const showResult = await configShow({ root: '.' });
//! if (showResult.success) {
//! console.log(`Strategy: ${showResult.data.strategy}`);
//! console.log(`Changeset path: ${showResult.data.changesetPath}`);
//! console.log(`History path: ${showResult.data.historyPath}`);
//! }
//!
//! // Validate configuration
//! const validateResult = await configValidate({ root: '.' });
//! if (validateResult.success) {
//! if (validateResult.data.valid) {
//! console.log('Configuration is valid');
//! } else {
//! console.log('Errors:', validateResult.data.errors);
//! console.log('Warnings:', validateResult.data.warnings);
//! }
//! }
//! ```
// TODO: will be implemented on story 7.2-7.3 - Config Commands
//
// Implementation outline for configShow:
//
// #[napi]
// pub async fn config_show(params: ConfigShowParams) -> JsonResponse<ConfigShowData> {
// // 1. Validate parameters
// if let Err(e) = validate_root(¶ms.root) {
// return JsonResponse::from_error_info(e);
// }
//
// // 2. Create Output with JSON format for capturing
// // 3. Call execute_show from CLI (commands/config.rs)
// // 4. Parse JSON response
// // 5. Return JsonResponse::success(data) or JsonResponse::error(msg)
// }
//
// Implementation outline for configValidate:
//
// #[napi]
// pub async fn config_validate(params: ConfigValidateParams) -> JsonResponse<ConfigValidateData> {
// // 1. Validate parameters
// if let Err(e) = validate_root(¶ms.root) {
// return JsonResponse::from_error_info(e);
// }
//
// // 2. Create Output with JSON format for capturing
// // 3. Call execute_validate from CLI (commands/config.rs)
// // 4. Parse JSON response containing valid, errors, warnings
// // 5. Return JsonResponse::success(data) or JsonResponse::error(msg)
// }