Skip to content

Commit

Permalink
Start on main.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jun 7, 2024
1 parent 3bc6e03 commit b875aa9
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ version = "0.0.1"
edition = "2021"
publish = false

[[bin]]
name = "moon"
path = "src/main.rs"

[dependencies]
moon_cache = { path = "../cache" }
moon_common = { path = "../common" }
Expand Down
5 changes: 4 additions & 1 deletion crates/app/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
mod app_error;
mod session;
mod systems;
pub mod systems;

pub use app_error::*;
pub use session::*;
34 changes: 34 additions & 0 deletions crates/app/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
mod app_error;
mod session;
mod systems;

use session::MoonSession;
use starbase::tracing::TracingOptions;
use starbase::{App, MainResult};
use starbase_utils::string_vec;

#[tokio::main]
async fn main() -> MainResult {
let app = App::default();
app.setup_diagnostics();

let _guard = app.setup_tracing(TracingOptions {
filter_modules: string_vec!["moon", "proto", "schematic", "starbase", "warpgate"],
log_env: "MOON_LOG".into(),
// log_file: cli.log_file.clone(),
// test_env: "MOON_TEST".into(),
..TracingOptions::default()
});

let mut session = MoonSession::new();

app.run(&mut session, |s| async move {
dbg!(&s);
println!("Hello");

Ok(())
})
.await?;

Ok(())
}
17 changes: 17 additions & 0 deletions crates/app/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use once_cell::sync::OnceCell;
use proto_core::ProtoEnvironment;
use starbase::{AppResult, AppSession};
use std::env;
use std::fmt;
use std::path::PathBuf;
use std::sync::Arc;

Expand All @@ -35,6 +36,7 @@ pub struct MoonSession {
pub working_dir: PathBuf,
pub workspace_root: PathBuf,
}

impl MoonSession {
pub fn new() -> Self {
Self {
Expand Down Expand Up @@ -73,6 +75,10 @@ impl MoonSession {

Ok(Arc::clone(item))
}

pub fn is_telemetry_enabled(&self) -> bool {
self.workspace_config.telemetry
}
}

#[async_trait]
Expand Down Expand Up @@ -106,3 +112,14 @@ impl AppSession for MoonSession {
Ok(())
}
}

impl fmt::Debug for MoonSession {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MoonSession")
.field("moon_env", &self.moon_env)
.field("tasks_config", &self.tasks_config)
.field("toolchain_config", &self.toolchain_config)
.field("workspace_config", &self.workspace_config)
.finish()
}
}
1 change: 1 addition & 0 deletions crates/env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct MoonEnvironment {
pub home: PathBuf, // ~
pub store_root: PathBuf, // ~/.moon
pub test_only: bool,
#[deprecated]
pub version: String,
pub working_dir: PathBuf,
pub workspace_root: PathBuf,
Expand Down

0 comments on commit b875aa9

Please sign in to comment.