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
//! Init command implementation for Node.js bindings.
//!
//! # What
//!
//! This module implements the `init` NAPI function that initializes
//! a new workspace configuration (repo.config) in the specified directory.
//!
//! # How
//!
//! The function:
//! 1. Validates the input parameters (root path, optional strategy/format)
//! 2. Calls `execute_init` from `sublime_cli_tools`
//! 3. Captures the JSON output
//! 4. Returns a `JsonResponse<InitData>`
//!
//! # Why
//!
//! The init command sets up the workspace configuration file that controls
//! versioning strategy, changeset paths, and other workspace settings.
//! It's typically the first command run when setting up a new workspace.
//!
//! # Examples
//!
//! ```typescript
//! import { init } from '@websublime/workspace-tools';
//!
//! // Initialize with default settings
//! const result = await init({ root: '.' });
//!
//! // Initialize with specific strategy
//! const result = await init({
//! root: '.',
//! strategy: 'independent',
//! format: 'toml'
//! });
//!
//! if (result.success) {
//! console.log(`Created config at: ${result.data.configPath}`);
//! console.log(`Strategy: ${result.data.strategy}`);
//! }
//! ```
// TODO: will be implemented on story 3.4 - Init Command
//
// Implementation outline:
//
// #[napi]
// pub async fn init(params: InitParams) -> JsonResponse<InitData> {
// // 1. Validate parameters
// if let Err(e) = validate_root(¶ms.root) {
// return JsonResponse::from_error_info(e);
// }
//
// // 2. Create InitArgs from params
// // 3. Create Output with JSON format for capturing
// // 4. Call execute_init from CLI
// // 5. Parse JSON response
// // 6. Return JsonResponse::success(data) or JsonResponse::error(msg)
// }