Skip to content

Commit f7aa7d5

Browse files
committed
wip
1 parent a188528 commit f7aa7d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+664
-459
lines changed

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Please run `cargo` commands with `--workspace` for better cache hits. Please prefer `cargo clippy` over `cargo check` and clear clippy warnings when you complete tasks. Please do not omit articles in error messages and comments and make comments complete sentences that end in periods.
1+
Please run `cargo` commands with `--workspace` for better cache hits. Please prefer `cargo clippy` over `cargo check` and clear clippy warnings when you complete tasks. Please do not omit articles in error messages and comments and make comments complete sentences that end in periods and do not use contractions.

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"packages/compiler",
88
"packages/database",
99
"packages/either",
10+
"packages/fdb",
1011
"packages/futures",
1112
"packages/http",
1213
"packages/ignore",
@@ -73,6 +74,7 @@ byte-unit = { version = "5", features = ["byte"] }
7374
byteorder = "1"
7475
bytes = { version = "1", features = ["serde"] }
7576
clap = { version = "4", features = ["derive", "env", "string", "unstable-v5"] }
77+
comfy-table = "7"
7678
console-subscriber = "0.4"
7779
crossterm = { version = "0.29", features = ["event-stream"] }
7880
dashmap = "6"
@@ -146,6 +148,7 @@ tangram_client = { path = "packages/client" }
146148
tangram_compiler = { path = "packages/compiler" }
147149
tangram_database = { path = "packages/database" }
148150
tangram_either = { path = "packages/either" }
151+
tangram_fdb = { path = "packages/fdb" }
149152
tangram_futures = { path = "packages/futures" }
150153
tangram_http = { path = "packages/http" }
151154
tangram_ignore = { path = "packages/ignore" }

packages/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ anstream = { workspace = true }
3636
byte-unit = { workspace = true }
3737
bytes = { workspace = true }
3838
clap = { workspace = true }
39+
comfy-table = { workspace = true }
3940
console-subscriber = { workspace = true }
4041
crossterm = { workspace = true }
4142
data-encoding = { workspace = true }

packages/cli/src/build.rs

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use {
22
crate::Cli,
3-
anstream::{eprintln, println},
4-
crossterm::style::Stylize as _,
53
futures::{FutureExt as _, TryStreamExt as _},
6-
std::path::PathBuf,
4+
std::{fmt::Write as _, path::PathBuf},
75
tangram_client::{self as tg, prelude::*},
86
tangram_futures::task::Task,
97
};
@@ -40,17 +38,8 @@ pub struct Options {
4038
#[arg(long, short)]
4139
pub detach: bool,
4240

43-
/// Whether to print blobs.
44-
#[arg(long)]
45-
pub print_blobs: bool,
46-
47-
/// The depth with which to print the output.
48-
#[arg(default_value = "0", long)]
49-
pub print_depth: crate::object::get::Depth,
50-
51-
/// Whether to pretty print the output.
52-
#[arg(long)]
53-
pub print_pretty: Option<bool>,
41+
#[command(flatten)]
42+
pub print: crate::print::ValueOptions,
5443

5544
#[command(flatten)]
5645
pub spawn: crate::process::spawn::Options,
@@ -93,17 +82,21 @@ impl Cli {
9382

9483
// If the detach flag is set, then print the process ID and return.
9584
if options.detach {
96-
Self::print_json(&output, None).await?;
85+
let options = crate::print::Options {
86+
json: options.print.json,
87+
pretty: options.print.pretty,
88+
};
89+
Self::print_one(output, options).await?;
9790
return Ok(());
9891
}
9992

10093
// Print the process.
10194
if !self.args.quiet {
102-
eprint!("{} {}", "info".blue().bold(), process.item().id());
95+
let mut message = process.item().id().to_string();
10396
if let Some(token) = process.item().token() {
104-
eprint!(" {token}");
97+
write!(message, " {token}").unwrap();
10598
}
106-
eprintln!();
99+
Self::print_info_message(&message);
107100
}
108101

109102
// Get the process's status.
@@ -265,21 +258,18 @@ impl Cli {
265258
.map_err(|source| tg::error!(!source, "failed to check out the artifact"))?;
266259

267260
// Print the path.
268-
println!("{}", path.display());
261+
let options = crate::print::Options {
262+
json: options.print.json,
263+
pretty: options.print.pretty,
264+
};
265+
Self::print_one(path, options).await?;
269266

270267
return Ok(());
271268
}
272269

273270
// Print the output.
274271
if !output.is_null() {
275-
Self::print_value(
276-
&handle,
277-
&output,
278-
options.print_depth,
279-
options.print_pretty,
280-
options.print_blobs,
281-
)
282-
.await?;
272+
Self::print_value(&handle, &output, options.print).await?;
283273
}
284274

285275
Ok(())

packages/cli/src/checkin.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ pub struct Args {
1515
#[arg(default_value = ".", index = 1)]
1616
pub path: Option<PathBuf>,
1717

18+
#[command(flatten)]
19+
pub print: crate::print::Options,
20+
1821
#[arg(
1922
action = clap::ArgAction::Append,
2023
long = "update",
@@ -189,7 +192,7 @@ impl Cli {
189192
let output = self.render_progress_stream(stream).await?;
190193

191194
// Print the artifact.
192-
println!("{}", output.referent.item);
195+
Self::print_one(output, args.print).await?;
193196

194197
Ok(())
195198
}

packages/cli/src/checkout.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ pub struct Args {
2323
#[arg(index = 2)]
2424
pub path: Option<PathBuf>,
2525

26+
#[command(flatten)]
27+
pub print: crate::print::Options,
28+
2629
/// The artifact to check out.
2730
#[arg(index = 1)]
2831
pub reference: tg::Reference,
@@ -124,8 +127,8 @@ impl Cli {
124127
.map_err(|source| tg::error!(!source, "failed to create the checkout stream"))?;
125128
let output = self.render_progress_stream(stream).await?;
126129

127-
// Print the path.
128-
println!("{}", output.path.display());
130+
// Print the output.
131+
Self::print_one(output, args.print).await?;
129132

130133
Ok(())
131134
}

packages/cli/src/children.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use {crate::Cli, tangram_client as tg, tangram_either::Either};
44
#[derive(Clone, Debug, clap::Args)]
55
#[group(skip)]
66
pub struct Args {
7+
#[command(flatten)]
8+
pub print: crate::print::Options,
9+
710
/// The object or process.
811
#[arg(default_value = ".", index = 1)]
912
pub reference: tg::Reference,
@@ -17,6 +20,7 @@ impl Cli {
1720
let args = crate::process::children::Args {
1821
length: None,
1922
position: None,
23+
print: args.print,
2024
process: process.id().clone(),
2125
remote: None,
2226
size: None,
@@ -26,6 +30,7 @@ impl Cli {
2630
Either::Right(object) => {
2731
let args = crate::object::children::Args {
2832
object: object.id(),
33+
print: args.print,
2934
};
3035
self.command_object_children(args).await?;
3136
},

packages/cli/src/clean.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use {
22
crate::Cli,
3-
crossterm::style::Stylize as _,
43
std::os::unix::fs::PermissionsExt as _,
54
tangram_client::{self as tg, prelude::*},
65
};
@@ -29,12 +28,11 @@ impl Cli {
2928
// Clean.
3029
let stream = handle.clean().await?;
3130
let output = self.render_progress_stream(stream).await?;
32-
eprintln!(
33-
"{} cleaned {} processes, {} objects",
34-
"info".blue().bold(),
35-
output.processes,
36-
output.objects,
31+
let message = format!(
32+
"cleaned {} processes, {} objects",
33+
output.processes, output.objects,
3734
);
35+
Self::print_info_message(&message);
3836

3937
Ok(())
4038
}

packages/cli/src/document.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ pub struct Args {
1111
#[arg(long)]
1212
pub locked: bool,
1313

14-
#[arg(long)]
15-
pub pretty: Option<bool>,
16-
1714
#[arg(default_value = ".", index = 1)]
1815
pub reference: tg::Reference,
1916

@@ -52,7 +49,7 @@ impl Cli {
5249
let output = handle.document(arg).await?;
5350

5451
// Print the document.
55-
Self::print_json(&output, args.pretty).await?;
52+
Self::print_json(output, None).await?;
5653

5754
Ok(())
5855
}

0 commit comments

Comments
 (0)