Skip to content

Commit 8101c6d

Browse files
committed
Support --layers squash-other, add colors to clap
1 parent 200ec5b commit 8101c6d

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11

2+
# v0.3.2
3+
4+
- General: Add color to CLI output.
5+
- `extract`: Add `--squash-other` mode.
6+
- `--layers squash-other`: Squash all layers other than the base layer.
7+
28
# v0.3.1
39

410
- `extract`: absolute symlinks are now correctly made relative to the target directory.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Extracts the contents of the image to disk.
5555
# Options for `circe extract`:
5656
# --layers
5757
# squash: Combines all layers into a single layer (default).
58+
# squash-other: Combines all layers except the base layer into a single layer.
5859
# base: Excludes all layers except the base layer.
5960
# separate: Exports each layer in a separate subdirectory.
6061
# --platform

bin/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ categories = ["command-line-utilities", "development-tools"]
1414
default-run = "circe"
1515

1616
[dependencies]
17-
clap = { version = "4.5.23", features = ["derive"] }
17+
clap = { version = "4.5.23", features = ["color", "derive"] }
1818
color-eyre = "0.6.3"
1919
tokio = { version = "1.42.0", features = ["full"] }
2020
tracing = "0.1.41"

bin/src/extract.rs

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ pub enum Mode {
119119
/// Only extract the base layer.
120120
Base,
121121

122+
/// Squash all "other" layers; "other" layers are all layers except the base layer.
123+
SquashOther,
124+
122125
/// Extract all layers to a separate directory for each layer.
123126
/// Also writes a `layers.json` file containing the list of layers in application order.
124127
Separate,
@@ -152,6 +155,7 @@ pub async fn main(opts: Options) -> Result<()> {
152155
let layers = registry.layers().await.context("list layers")?;
153156
match opts.layers {
154157
Mode::Squash => squash(&registry, &output, layers).await,
158+
Mode::SquashOther => squash(&registry, &output, layers.into_iter().skip(1)).await,
155159
Mode::Base => squash(&registry, &output, layers.into_iter().take(1)).await,
156160
Mode::Separate => separate(&registry, &output, layers).await,
157161
}

bin/src/main.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
use clap::Parser;
1+
use clap::{
2+
builder::{styling::AnsiColor, Styles},
3+
Parser,
4+
};
25
use color_eyre::eyre::Result;
36
use tracing::level_filters::LevelFilter;
47
use tracing_subscriber::{self, prelude::*};
58

69
mod extract;
710
mod list;
811
#[derive(Debug, Parser)]
9-
#[command(author, version, about)]
12+
#[command(version, about, styles = style())]
1013
struct Cli {
1114
#[command(subcommand)]
1215
command: Commands,
@@ -54,3 +57,14 @@ async fn main() -> Result<()> {
5457

5558
Ok(())
5659
}
60+
61+
fn style() -> Styles {
62+
Styles::styled()
63+
.header(AnsiColor::Yellow.on_default())
64+
.usage(AnsiColor::Green.on_default())
65+
.literal(AnsiColor::Green.on_default())
66+
.placeholder(AnsiColor::Green.on_default())
67+
.error(AnsiColor::Red.on_default())
68+
.invalid(AnsiColor::Red.on_default())
69+
.valid(AnsiColor::Blue.on_default())
70+
}

0 commit comments

Comments
 (0)