1use oxdock_cli::{parse_script, run_script};
4use oxdock_fs::GuardedPath;
5
6const SCRIPT: &str = r#"
8# Build a demo tree and explore it interactively.
9WORKDIR /
10MKDIR demo/assets
11MKDIR demo/logs
12WRITE demo/assets/hello.txt hello
13LS demo
14WORKDIR demo
15# To drop into the demo workspace after running the script, run this example with
16# the CLI `--shell` flag (e.g. `cargo run --example tree_shell -- --shell`).
17"#;
18
19fn main() -> anyhow::Result<()> {
20 let temp = GuardedPath::tempdir()?;
21 let root = temp.as_guarded_path().clone();
22
23 println!("temp workspace: {}", temp.display());
24 println!("script:\n{SCRIPT}");
25 println!(
26 "You'll be dropped into 'demo' inside the temp workspace. Exit the shell to finish the example.\n"
27 );
28
29 let steps = parse_script(SCRIPT)?;
30 run_script(&root, &steps)
31}