Skip to content

Commit 8c8c46f

Browse files
committed
feat: add CLI for api server
1 parent f0e82b7 commit 8c8c46f

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/api_server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ version = "0.1.0"
99
[dependencies]
1010
anyhow = { workspace = true }
1111
serde = { workspace = true }
12+
clap = { workspace = true }
1213

1314
actix-web = "4"
1415
actix-cors = "0.7"

crates/api_server/src/main.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use actix_cors::Cors;
22
use actix_web::{error, get, web, App, HttpServer, Result};
3+
use clap::Parser;
34
use dt_core::{
45
graph::used_by_graph::UsedByGraph,
56
portable::Portable,
@@ -140,12 +141,18 @@ async fn search(
140141
}))
141142
}
142143

144+
#[derive(Parser)]
145+
#[command(version, about = "Start the server to provide search API", long_about = None)]
146+
struct Cli {
147+
/// Portable path
148+
#[arg(short)]
149+
portable: String,
150+
}
151+
143152
#[actix_web::main]
144153
async fn main() -> std::io::Result<()> {
145-
// TODO: get portable path from args
146-
// let mut file = File::open("<the portable path>")?;
147-
let mut file =
148-
File::open("/Users/linweitang/rust/js-symbol-dependency-tracker/outputs/naopleon-06.json")?;
154+
let cli = Cli::parse();
155+
let mut file = File::open(cli.portable)?;
149156
let mut exported = String::new();
150157
file.read_to_string(&mut exported)?;
151158
let portable = Portable::import(&exported).unwrap();

0 commit comments

Comments
 (0)