Skip to content

Commit eba92d2

Browse files
committed
feat(ie-shell): add CLI argument parsing and headless mode #6
Add clap-based CLI with --headless, --url, --dump-source, --dump-status, and --allow-http flags. Split main.rs into app.rs (GUI browser), cli.rs (argument parsing), and headless.rs (headless execution path). Remove Phase 2 crate dependencies from ie-shell for faster builds. 11 CLI unit tests + 2 smoke integration tests.
1 parent 9ac0bc3 commit eba92d2

8 files changed

Lines changed: 467 additions & 56 deletions

File tree

Cargo.lock

Lines changed: 121 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ rustls = "0.23"
5050
url = "2"
5151
serde = { version = "1", features = ["derive"] }
5252
serde_json = "1"
53+
clap = { version = "4", features = ["derive"] }
5354
bytes = "1"

crates/ie-shell/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ tracing-subscriber.workspace = true
1515
tokio.workspace = true
1616
winit.workspace = true
1717
url.workspace = true
18+
clap.workspace = true
1819
ie-net.workspace = true
19-
ie-html.workspace = true
20-
ie-css.workspace = true
2120
ie-dom.workspace = true
22-
ie-js.workspace = true
23-
ie-layout.workspace = true
24-
ie-render.workspace = true
2521
ie-sandbox.workspace = true

crates/ie-shell/src/app.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use url::Url;
2+
use winit::application::ApplicationHandler;
3+
use winit::event::WindowEvent;
4+
use winit::event_loop::ActiveEventLoop;
5+
use winit::window::{Window, WindowId};
6+
7+
pub struct Browser {
8+
window: Option<Window>,
9+
_url: Option<Url>,
10+
}
11+
12+
impl Browser {
13+
pub fn new(url: Option<Url>) -> Self {
14+
Self {
15+
window: None,
16+
_url: url,
17+
}
18+
}
19+
}
20+
21+
impl ApplicationHandler for Browser {
22+
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
23+
if self.window.is_none() {
24+
let attrs = Window::default_attributes()
25+
.with_title("Internet Exploder")
26+
.with_maximized(true);
27+
match event_loop.create_window(attrs) {
28+
Ok(window) => self.window = Some(window),
29+
Err(e) => {
30+
tracing::error!("failed to create window: {e}");
31+
event_loop.exit();
32+
}
33+
}
34+
}
35+
}
36+
37+
fn window_event(
38+
&mut self,
39+
event_loop: &ActiveEventLoop,
40+
_window_id: WindowId,
41+
event: WindowEvent,
42+
) {
43+
match event {
44+
WindowEvent::CloseRequested => {
45+
event_loop.exit();
46+
}
47+
WindowEvent::RedrawRequested => {
48+
// TODO: render current page
49+
}
50+
_ => {}
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)