excel_cli/cli/
envelope.rs1use serde_json::{json, Value};
2
3pub fn success_envelope(
5 command: &str,
6 file_path: &str,
7 file_format: &str,
8 target: Value,
9 meta: Value,
10 data: Value,
11 warnings: Vec<Value>,
12) -> Value {
13 json!({
14 "schema_version": "1.0",
15 "command": command,
16 "file": {
17 "path": file_path,
18 "format": file_format,
19 },
20 "target": target,
21 "meta": meta,
22 "data": data,
23 "warnings": warnings,
24 })
25}
26
27pub fn target_workbook() -> Value {
29 json!({})
30}
31
32pub fn target_sheet(sheet_name: &str, sheet_index: usize) -> Value {
34 json!({
35 "sheet": sheet_name,
36 "sheet_index": sheet_index,
37 })
38}
39
40pub fn target_range(sheet_name: &str, sheet_index: usize, range: &str) -> Value {
42 json!({
43 "sheet": sheet_name,
44 "sheet_index": sheet_index,
45 "range": range,
46 })
47}
48
49pub fn target_cell(sheet_name: &str, sheet_index: usize, cell: &str) -> Value {
51 json!({
52 "sheet": sheet_name,
53 "sheet_index": sheet_index,
54 "cell": cell,
55 })
56}