Skip to content

Commit 8af2b03

Browse files
authored
fix: fix the difference of python CLI and rust CLI (#188)
* fix: optimize grep and find output * fix: optimize grep and find output * fix: --json is not useful, remove * fix: show full uri
1 parent c138062 commit 8af2b03

File tree

19 files changed

+501
-168
lines changed

19 files changed

+501
-168
lines changed

crates/ov_cli/src/commands/content.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub async fn read(
66
client: &HttpClient,
77
uri: &str,
88
_output_format: OutputFormat,
9+
_compact: bool,
910
) -> Result<()> {
1011
let content = client.read(uri).await?;
1112
println!("{}", content);
@@ -16,6 +17,7 @@ pub async fn abstract_content(
1617
client: &HttpClient,
1718
uri: &str,
1819
_output_format: OutputFormat,
20+
_compact: bool,
1921
) -> Result<()> {
2022
let content = client.abstract_content(uri).await?;
2123
println!("{}", content);
@@ -26,6 +28,7 @@ pub async fn overview(
2628
client: &HttpClient,
2729
uri: &str,
2830
_output_format: OutputFormat,
31+
_compact: bool,
2932
) -> Result<()> {
3033
let content = client.overview(uri).await?;
3134
println!("{}", content);

crates/ov_cli/src/commands/filesystem.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,29 @@ pub async fn ls(
88
simple: bool,
99
recursive: bool,
1010
output_format: OutputFormat,
11+
compact: bool,
1112
) -> Result<()> {
1213
let result = client.ls(uri, simple, recursive).await?;
13-
output_success(&result, output_format, false);
14+
output_success(&result, output_format, compact);
1415
Ok(())
1516
}
1617

1718
pub async fn tree(
1819
client: &HttpClient,
1920
uri: &str,
2021
output_format: OutputFormat,
22+
compact: bool,
2123
) -> Result<()> {
2224
let result = client.tree(uri).await?;
23-
output_success(&result, output_format, false);
25+
output_success(&result, output_format, compact);
2426
Ok(())
2527
}
2628

2729
pub async fn mkdir(
2830
client: &HttpClient,
2931
uri: &str,
3032
_output_format: OutputFormat,
33+
_compact: bool,
3134
) -> Result<()> {
3235
client.mkdir(uri).await?;
3336
println!("Directory created: {}", uri);
@@ -39,6 +42,7 @@ pub async fn rm(
3942
uri: &str,
4043
recursive: bool,
4144
_output_format: OutputFormat,
45+
_compact: bool,
4246
) -> Result<()> {
4347
client.rm(uri, recursive).await?;
4448
println!("Removed: {}", uri);
@@ -50,6 +54,7 @@ pub async fn mv(
5054
from_uri: &str,
5155
to_uri: &str,
5256
_output_format: OutputFormat,
57+
_compact: bool,
5358
) -> Result<()> {
5459
client.mv(from_uri, to_uri).await?;
5560
println!("Moved: {} -> {}", from_uri, to_uri);
@@ -60,8 +65,9 @@ pub async fn stat(
6065
client: &HttpClient,
6166
uri: &str,
6267
output_format: OutputFormat,
68+
compact: bool,
6369
) -> Result<()> {
6470
let result = client.stat(uri).await?;
65-
output_success(&result, output_format, false);
71+
output_success(&result, output_format, compact);
6672
Ok(())
6773
}

crates/ov_cli/src/commands/observer.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,39 @@ use crate::output::{output_success, OutputFormat};
55
pub async fn queue(
66
client: &HttpClient,
77
output_format: OutputFormat,
8+
compact: bool,
89
) -> Result<()> {
910
let response: serde_json::Value = client.get("/api/v1/observer/queue", &[]).await?;
10-
output_success(&response, output_format, false);
11+
output_success(&response, output_format, compact);
1112
Ok(())
1213
}
1314

1415
pub async fn vikingdb(
1516
client: &HttpClient,
1617
output_format: OutputFormat,
18+
compact: bool,
1719
) -> Result<()> {
1820
let response: serde_json::Value = client.get("/api/v1/observer/vikingdb", &[]).await?;
19-
output_success(&response, output_format, false);
21+
output_success(&response, output_format, compact);
2022
Ok(())
2123
}
2224

2325
pub async fn vlm(
2426
client: &HttpClient,
2527
output_format: OutputFormat,
28+
compact: bool,
2629
) -> Result<()> {
2730
let response: serde_json::Value = client.get("/api/v1/observer/vlm", &[]).await?;
28-
output_success(&response, output_format, false);
31+
output_success(&response, output_format, compact);
2932
Ok(())
3033
}
3134

3235
pub async fn system(
3336
client: &HttpClient,
3437
output_format: OutputFormat,
38+
compact: bool,
3539
) -> Result<()> {
3640
let response: serde_json::Value = client.get("/api/v1/observer/system", &[]).await?;
37-
output_success(&response, output_format, false);
41+
output_success(&response, output_format, compact);
3842
Ok(())
3943
}

crates/ov_cli/src/commands/pack.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ pub async fn export(
77
uri: &str,
88
to: &str,
99
format: OutputFormat,
10+
compact: bool,
1011
) -> Result<()> {
1112
let result = client.export_ovpack(uri, to).await?;
12-
output_success(&result, format, false);
13+
output_success(&result, format, compact);
1314
Ok(())
1415
}
1516

@@ -20,11 +21,12 @@ pub async fn import(
2021
force: bool,
2122
no_vectorize: bool,
2223
format: OutputFormat,
24+
compact: bool,
2325
) -> Result<()> {
2426
let vectorize = !no_vectorize;
2527
let result = client
2628
.import_ovpack(file_path, target, force, vectorize)
2729
.await?;
28-
output_success(&result, format, false);
30+
output_success(&result, format, compact);
2931
Ok(())
3032
}

crates/ov_cli/src/commands/relations.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ pub async fn list_relations(
66
client: &HttpClient,
77
uri: &str,
88
format: OutputFormat,
9+
compact: bool,
910
) -> Result<()> {
1011
let result = client.relations(uri).await?;
11-
output_success(&result, format, false);
12+
output_success(&result, format, compact);
1213
Ok(())
1314
}
1415

@@ -18,6 +19,7 @@ pub async fn link(
1819
to_uris: &Vec<String>,
1920
reason: &str,
2021
format: OutputFormat,
22+
compact: bool,
2123
) -> Result<()> {
2224
let result = client.link(from_uri, to_uris, reason).await?;
2325
// If the server returns null/empty, show a confirmation summary
@@ -27,9 +29,9 @@ pub async fn link(
2729
"to": to_uris,
2830
"reason": reason,
2931
});
30-
output_success(&summary, format, false);
32+
output_success(&summary, format, compact);
3133
} else {
32-
output_success(&result, format, false);
34+
output_success(&result, format, compact);
3335
}
3436
Ok(())
3537
}
@@ -39,16 +41,17 @@ pub async fn unlink(
3941
from_uri: &str,
4042
to_uri: &str,
4143
format: OutputFormat,
44+
compact: bool,
4245
) -> Result<()> {
4346
let result = client.unlink(from_uri, to_uri).await?;
4447
if result.is_null() {
4548
let summary = serde_json::json!({
4649
"from": from_uri,
4750
"to": to_uri,
4851
});
49-
output_success(&summary, format, false);
52+
output_success(&summary, format, compact);
5053
} else {
51-
output_success(&result, format, false);
54+
output_success(&result, format, compact);
5255
}
5356
Ok(())
5457
}

crates/ov_cli/src/commands/resources.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ pub async fn add_resource(
1111
wait: bool,
1212
timeout: Option<f64>,
1313
format: OutputFormat,
14+
compact: bool,
1415
) -> Result<()> {
1516
let result = client
1617
.add_resource(path, to, &reason, &instruction, wait, timeout)
1718
.await?;
18-
output_success(&result, format, false);
19+
output_success(&result, format, compact);
1920
Ok(())
2021
}
2122

@@ -25,8 +26,9 @@ pub async fn add_skill(
2526
wait: bool,
2627
timeout: Option<f64>,
2728
format: OutputFormat,
29+
compact: bool,
2830
) -> Result<()> {
2931
let result = client.add_skill(data, wait, timeout).await?;
30-
output_success(&result, format, false);
32+
output_success(&result, format, compact);
3133
Ok(())
3234
}

crates/ov_cli/src/commands/search.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ pub async fn find(
99
limit: i32,
1010
threshold: Option<f64>,
1111
output_format: OutputFormat,
12+
compact: bool,
1213
) -> Result<()> {
1314
let result = client.find(query.to_string(), uri.to_string(), limit, threshold).await?;
14-
output_success(&result, output_format, false);
15+
output_success(&result, output_format, compact);
1516
Ok(())
1617
}
1718

@@ -23,9 +24,10 @@ pub async fn search(
2324
limit: i32,
2425
threshold: Option<f64>,
2526
output_format: OutputFormat,
27+
compact: bool,
2628
) -> Result<()> {
2729
let result = client.search(query.to_string(), uri.to_string(), session_id, limit, threshold).await?;
28-
output_success(&result, output_format, false);
30+
output_success(&result, output_format, compact);
2931
Ok(())
3032
}
3133

@@ -35,9 +37,10 @@ pub async fn grep(
3537
pattern: &str,
3638
ignore_case: bool,
3739
output_format: OutputFormat,
40+
compact: bool,
3841
) -> Result<()> {
3942
let result = client.grep(uri, pattern, ignore_case).await?;
40-
output_success(&result, output_format, false);
43+
output_success(&result, output_format, compact);
4144
Ok(())
4245
}
4346

@@ -46,8 +49,9 @@ pub async fn glob(
4649
pattern: &str,
4750
uri: &str,
4851
output_format: OutputFormat,
52+
compact: bool,
4953
) -> Result<()> {
5054
let result = client.glob(pattern, uri).await?;
51-
output_success(&result, output_format, false);
55+
output_success(&result, output_format, compact);
5256
Ok(())
5357
}

crates/ov_cli/src/commands/session.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,40 @@ use serde_json::json;
66
pub async fn new_session(
77
client: &HttpClient,
88
output_format: OutputFormat,
9+
compact: bool,
910
) -> Result<()> {
1011
let response: serde_json::Value = client.post("/api/v1/sessions", &json!({})).await?;
11-
output_success(&response, output_format, false);
12+
output_success(&response, output_format, compact);
1213
Ok(())
1314
}
1415

1516
pub async fn list_sessions(
1617
client: &HttpClient,
1718
output_format: OutputFormat,
19+
compact: bool,
1820
) -> Result<()> {
1921
let response: serde_json::Value = client.get("/api/v1/sessions", &[]).await?;
20-
output_success(&response, output_format, false);
22+
output_success(&response, output_format, compact);
2123
Ok(())
2224
}
2325

2426
pub async fn get_session(
2527
client: &HttpClient,
2628
session_id: &str,
2729
output_format: OutputFormat,
30+
compact: bool,
2831
) -> Result<()> {
2932
let path = format!("/api/v1/sessions/{}", url_encode(session_id));
3033
let response: serde_json::Value = client.get(&path, &[]).await?;
31-
output_success(&response, output_format, false);
34+
output_success(&response, output_format, compact);
3235
Ok(())
3336
}
3437

3538
pub async fn delete_session(
3639
client: &HttpClient,
3740
session_id: &str,
3841
output_format: OutputFormat,
42+
compact: bool,
3943
) -> Result<()> {
4044
let path = format!("/api/v1/sessions/{}", url_encode(session_id));
4145
let response: serde_json::Value = client.delete(&path, &[]).await?;
@@ -47,7 +51,7 @@ pub async fn delete_session(
4751
response
4852
};
4953

50-
output_success(&result, output_format, false);
54+
output_success(&result, output_format, compact);
5155
Ok(())
5256
}
5357

@@ -57,6 +61,7 @@ pub async fn add_message(
5761
role: &str,
5862
content: &str,
5963
output_format: OutputFormat,
64+
compact: bool,
6065
) -> Result<()> {
6166
let path = format!("/api/v1/sessions/{}/messages", url_encode(session_id));
6267
let body = json!({
@@ -65,18 +70,19 @@ pub async fn add_message(
6570
});
6671

6772
let response: serde_json::Value = client.post(&path, &body).await?;
68-
output_success(&response, output_format, false);
73+
output_success(&response, output_format, compact);
6974
Ok(())
7075
}
7176

7277
pub async fn commit_session(
7378
client: &HttpClient,
7479
session_id: &str,
7580
output_format: OutputFormat,
81+
compact: bool,
7682
) -> Result<()> {
7783
let path = format!("/api/v1/sessions/{}/commit", url_encode(session_id));
7884
let response: serde_json::Value = client.post(&path, &json!({})).await?;
79-
output_success(&response, output_format, false);
85+
output_success(&response, output_format, compact);
8086
Ok(())
8187
}
8288

0 commit comments

Comments
 (0)