Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cli/src/build_project.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::process::{Command, Stdio};

use crate::workspace::*;
use crate::BuildArgs;
use std::process::{Command, Stdio};

pub fn build_project(_args: BuildArgs) -> anyhow::Result<()> {
verify_steel_workspace()?;

Command::new("cargo")
.arg("build-sbf")
.stdout(Stdio::inherit())
Expand Down
1 change: 1 addition & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod new_project;
mod program_keys;
mod test_project;
mod utils;
mod workspace;

use args::*;
use build_project::*;
Expand Down
12 changes: 7 additions & 5 deletions cli/src/test_project.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use crate::workspace::*;
use std::process::{Command, Stdio};

use crate::TestArgs;

pub fn test_project(args: TestArgs) -> anyhow::Result<()> {
verify_steel_workspace()?;
let mut command = Command::new("cargo");
command.arg("test-sbf");
command.arg("test-sbf");

if args.nocapture {
command.arg("--").arg("--nocapture");
}
if args.nocapture {
command.arg("--").arg("--nocapture");
}

command
command
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()
Expand Down
23 changes: 23 additions & 0 deletions cli/src/workspace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// src/utils.rs or src/workspace.rs
use anyhow::{Context, Result};
use std::fs;
use std::path::PathBuf;

pub fn verify_steel_workspace() -> Result<PathBuf> {
let current_dir = std::env::current_dir().context("Failed to get current directory")?;

let cargo_toml_path = current_dir.join("Cargo.toml");

if !cargo_toml_path.exists() {
anyhow::bail!("Error: Not in a Steel workspace.\n\nNo Cargo.toml found. Run 'steel new <name>' to create a new Steel project.");
}

let cargo_toml_content =
fs::read_to_string(&cargo_toml_path).context("Failed to read Cargo.toml")?;

if !cargo_toml_content.contains("steel") {
anyhow::bail!("Error: Not in a Steel workspace.\n\n. Run 'steel new <name>' to create a new Steel project.");
}

Ok(current_dir)
}