Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for projects with both gel.toml and edgedb.toml #1479

Merged
merged 3 commits into from
Feb 17, 2025
Merged
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
33 changes: 24 additions & 9 deletions src/portable/project/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ use clap::ValueHint;
use const_format::concatcp;
use gel_tokio::get_stash_path;

use crate::branding::BRANDING_CLI_CMD;
use crate::branding::BRANDING_CLOUD;
use crate::branding::{BRANDING_CLI_CMD, MANIFEST_FILE_DISPLAY_NAME};
use crate::commands::ExitCode;
use crate::portable::project;
use crate::print::{self, msg, Highlight};
use crate::table;

pub fn run(options: &Command) -> anyhow::Result<()> {
let Some(project) = project::find_project(options.project_dir.as_deref())? else {
anyhow::bail!("`{MANIFEST_FILE_DISPLAY_NAME}` not found, unable to get project info.");
};
let stash_dir = get_stash_path(&project.root)?;
let ctx = project::ensure_ctx(options.project_dir.as_deref())?;
let schema_dir = ctx.resolve_schema_dir()?;

let stash_dir = get_stash_path(&ctx.location.root)?;
if !stash_dir.exists() {
msg!(
"{} {} Run `{BRANDING_CLI_CMD} project init`.",
Expand Down Expand Up @@ -52,6 +52,13 @@ pub fn run(options: &Command) -> anyhow::Result<()> {
println!("{profile}");
}
}
"schema-dir" => {
if options.json {
println!("{}", serde_json::to_string(&schema_dir)?);
} else {
println!("{}", schema_dir.display());
}
}
_ => unreachable!(),
}
} else if options.json {
Expand All @@ -60,13 +67,19 @@ pub fn run(options: &Command) -> anyhow::Result<()> {
serde_json::to_string_pretty(&JsonInfo {
instance_name: &instance_name,
cloud_profile: cloud_profile.as_deref(),
root: &project.root,
root: &ctx.location.root,
schema_dir: &schema_dir,
})?
);
} else {
let root = project.root.display().to_string();
let mut rows: Vec<(&str, String)> =
vec![("Instance name", instance_name), ("Project root", root)];
let root = ctx.location.root.display().to_string();
let schema_dir = schema_dir.display().to_string();

let mut rows: Vec<(&str, String)> = vec![
("Instance name", instance_name),
("Project root", root),
("Schema dir", schema_dir),
];
if let Some(profile) = cloud_profile.as_deref() {
rows.push((concatcp!(BRANDING_CLOUD, " profile"), profile.to_string()));
}
Expand All @@ -92,6 +105,7 @@ pub struct Command {
#[arg(long, value_parser=[
"instance-name",
"cloud-profile",
"schema-dir",
])]
/// Get a specific value:
///
Expand All @@ -106,4 +120,5 @@ struct JsonInfo<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
cloud_profile: Option<&'a str>,
root: &'a Path,
schema_dir: &'a Path,
}
Loading