Skip to content

Commit 26c1a58

Browse files
committed
feat: improve the --version output
1 parent 8872617 commit 26c1a58

File tree

10 files changed

+134
-42
lines changed

10 files changed

+134
-42
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
!crates/
33
!Cargo.toml
44
!Cargo.lock
5-
.env
5+
.env
6+
!.git/**

.github/workflows/build.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,31 @@ concurrency:
2424
jobs:
2525

2626
check:
27-
name: Check ${{ matrix.package }}
27+
name: Check ${{ matrix.package.name }}
2828
runs-on: ubuntu-latest
2929
strategy:
3030
matrix:
3131
package:
32-
- "yozefu-lib"
33-
- "yozefu-app"
34-
- "yozefu-command"
35-
- "yozefu-tui"
36-
- "yozefu-wasm-types"
37-
- "yozefu"
32+
- name: yozefu-lib
33+
command: cargo check --locked --package yozefu-lib
34+
- name: yozefu-app
35+
command: cargo check --locked --package yozefu-app
36+
- name: yozefu-command
37+
command: cargo check --locked --package yozefu-command
38+
- name: yozefu-tui
39+
command: cargo check --locked --package yozefu-tui
40+
- name: yozefu-wasm-types
41+
command: cargo check --locked --package yozefu-wasm-types
42+
- name: yozefu
43+
command: cargo run --locked -- --version
3844
steps:
3945
- uses: actions/checkout@v4
4046
- uses: actions-rust-lang/setup-rust-toolchain@v1
4147
with:
4248
toolchain: stable
4349
- uses: Swatinem/rust-cache@v2
4450
- name: Run cargo check
45-
run: cargo check --locked --release --package ${{ matrix.package }}
51+
run: ${{ matrix.package.command }}
4652

4753
build:
4854
name: Build w/o features
@@ -193,7 +199,7 @@ jobs:
193199
docker:
194200
name: Docker image
195201
runs-on: ubuntu-latest
196-
needs: [check]
202+
# needs: [check]
197203
permissions:
198204
contents: read
199205
packages: write
@@ -204,13 +210,12 @@ jobs:
204210
uses: actions/checkout@v4
205211
- name: Set up Docker Buildx
206212
uses: docker/setup-buildx-action@v3
207-
- name: Build and push
213+
- name: Build
208214
uses: docker/build-push-action@v6
209-
id: push
210215
with:
211216
push: false
212-
cache-from: type=gha
213-
cache-to: type=gha,mode=max
217+
#cache-from: type=gha
218+
#cache-to: type=gha,mode=max
214219

215220
typos:
216221
name: Typos

Cargo.lock

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

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM rust:1-slim-bookworm AS builder
22
WORKDIR /app
3+
COPY .git .git
34
RUN --mount=type=bind,source=crates,target=crates \
45
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
56
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \
@@ -8,6 +9,7 @@ RUN --mount=type=bind,source=crates,target=crates \
89
<<EOF
910
set -e
1011
apt-get update && apt-get install --no-install-recommends -y build-essential cmake libclang-dev
12+
ls -lah
1113
cargo build --release --all-features --locked
1214
cp ./target/release/yozf /tmp/yozf
1315
EOF

crates/command/Cargo.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,21 @@ rdkafka = { version = "0.37.0", features = [
4040
"libz-static",
4141
"curl-static",
4242
"zstd",
43-
"external-lz4"
43+
"external-lz4",
4444
] }
4545
extism = { version = "1.10.0" }
4646
indexmap = "2.8.0"
4747
tui = { workspace = true }
4848
app = { workspace = true }
4949
lib = { workspace = true }
5050
reqwest = { version = "0.12.15", features = ["json"] }
51+
const_format = { version = "0.2.34", features = ["rust_1_64"] }
52+
const-str = "0.6.2"
5153

5254
[features]
53-
ssl-vendored = [
54-
"rdkafka/ssl-vendored",
55-
"tui/ssl-vendored",
56-
"app/ssl-vendored"
57-
]
55+
ssl-vendored = ["rdkafka/ssl-vendored", "tui/ssl-vendored", "app/ssl-vendored"]
5856
gssapi-vendored = [
5957
"rdkafka/gssapi-vendored",
6058
"tui/gssapi-vendored",
61-
"app/gssapi-vendored"
59+
"app/gssapi-vendored",
6260
]

crates/command/src/cli.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
use crate::cluster::Cluster;
33
use crate::command::{Command, MainCommand, UtilityCommands};
44
use crate::theme::init_themes_file;
5+
use crate::version::VERSION_MESSAGE;
56
use app::APPLICATION_NAME;
67
use app::configuration::{ClusterConfig, GlobalConfig, SchemaRegistryConfig, YozefuConfig};
78
use clap::command;
@@ -14,14 +15,6 @@ use tui::error::TuiError;
1415
pub use clap::Parser;
1516
use indexmap::IndexMap;
1617

17-
const VERSION_MESSAGE: &str = concat!(
18-
env!("CARGO_PKG_VERSION"),
19-
"\n",
20-
env!("CARGO_PKG_REPOSITORY"),
21-
"\n",
22-
env!("CARGO_PKG_AUTHORS")
23-
);
24-
2518
// https://github.com/clap-rs/clap/issues/975
2619
/// CLI parser
2720
#[derive(Parser)]

crates/command/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod command;
77
mod headless;
88
mod log;
99
mod theme;
10+
mod version;
1011
use app::configuration::GlobalConfig;
1112
pub use clap::Parser;
1213
pub use cli::Cli;

crates/command/src/version.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//! Inspired of <https://vallentin.dev/blog/post/versioning>
2+
//!
3+
//! Github environment variables <https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables>
4+
//! The version message looks like this:
5+
//! ```
6+
//! yozefu 0.0.9 (develop:unknown, debug build, macos [aarch64])
7+
//! https://github.com/MAIF/yozefu
8+
//! Yann Prono <[email protected]>
9+
//! ```
10+
use const_format::{formatcp, str_index, str_split};
11+
use const_str::split_lines;
12+
use std::env::consts::{ARCH, OS};
13+
14+
#[cfg(debug_assertions)]
15+
const BUILD_TYPE: &str = "debug";
16+
17+
#[cfg(not(debug_assertions))]
18+
const BUILD_TYPE: &'static str = "release";
19+
20+
const GIT_BRANCH: &str = match option_env!("GITHUB_REF_NAME") {
21+
Some(v) => v,
22+
None => {
23+
const FIRST_LINE: &str = split_lines!(include_str!("../../../.git/HEAD"))[0];
24+
str_split!(FIRST_LINE, "/")[2]
25+
}
26+
};
27+
28+
const GIT_COMMIT: &str = match option_env!("GITHUB_SHA") {
29+
Some(v) => v,
30+
None => "unknown",
31+
};
32+
33+
pub(super) const VERSION_MESSAGE: &str = formatcp!(
34+
"{} ({}:{}, {} build, {} [{}]) \n{}\n{}",
35+
env!("CARGO_PKG_VERSION"),
36+
GIT_BRANCH,
37+
str_index!(GIT_COMMIT, 0..7),
38+
BUILD_TYPE,
39+
OS,
40+
ARCH,
41+
env!("CARGO_PKG_REPOSITORY"),
42+
env!("CARGO_PKG_AUTHORS"),
43+
);

deny.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ exceptions = [
110110
{ allow = ["BSL-1.0"], crate = "lazy-bytes-cast" },
111111
{ allow = ["Zlib"], crate = "throbber-widgets-tui" },
112112
{ allow = ["Zlib"], crate = "adler32" },
113+
{ allow = ["Zlib"], crate = "const_format" },
114+
{ allow = ["Zlib"], crate = "konst_macro_rules" },
115+
{ allow = ["Zlib"], crate = "const_format_proc_macros" },
116+
{ allow = ["Zlib"], crate = "konst" }
113117
]
114118

115119
# Some crates don't have (easily) machine readable licensing information,

docs/keybindings/README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ The choices I made are completely personal. I use a qwerty apple keyboard for yo
3232
<br />
3333

3434
**Records list**
35-
| Keybinding | Description |
36-
| ---------------------------- | :-------------------------------------------- |
37-
| <kbd>C</kbd> | Copy kafka record to clipboard |
38-
| <kbd>O</kbd> | Open the kafka record in the web browser |
39-
| <kbd>E</kbd> | Export kafka record to the file |
40-
| <kbd>F</kbd> | Keep selecting the last consumed kafka record |
41-
| <kbd>Enter</kbd> | Open the selected record |
42-
| <kbd>↑</kbd> or <kbd>↓</kbd> | Previous/next record |
35+
| Keybinding | Description |
36+
| ------------------------------ | :-------------------------------------------- |
37+
| <kbd>C</kbd> | Copy kafka record to clipboard |
38+
| <kbd>O</kbd> | Open the kafka record in the web browser |
39+
| <kbd>E</kbd> | Export kafka record to the file |
40+
| <kbd>Ctrl</kbd> + <kbd>E</kbd> | Export all records to the file |
41+
| <kbd>F</kbd> | Keep selecting the last consumed kafka record |
42+
| <kbd>Enter</kbd> | Open the selected record |
43+
| <kbd>↑</kbd> or <kbd>↓</kbd> | Previous/next record |
4344

4445

4546
<br />
@@ -68,8 +69,8 @@ The choices I made are completely personal. I use a qwerty apple keyboard for yo
6869

6970

7071
**Search**
71-
| Keybinding | Description |
72-
| ---------------------------- | :-------------------- |
73-
| <kbd>↓</kbd> or <kbd>↑</kbd> | Browse history |
74-
| <kbd>→</kbd> | Accept autocomplete |
75-
| <kbd>Enter</kbd> | Search kafka records |
72+
| Keybinding | Description |
73+
| ---------------------------- | :------------------- |
74+
| <kbd>↓</kbd> or <kbd>↑</kbd> | Browse history |
75+
| <kbd>→</kbd> | Accept autocomplete |
76+
| <kbd>Enter</kbd> | Search kafka records |

0 commit comments

Comments
 (0)