Canop / dysk

A linux utility to get information on filesystems, like df but better
https://dystroy.org/dysk
MIT License
890 stars 25 forks source link

version 2.8.0 - printing wrong version #65

Closed daniejstriata closed 1 year ago

daniejstriata commented 1 year ago

The --version output is still 2.7.2 instead of 2.8.0.

image

Canop commented 1 year ago

Oh sh. And I know I'll fall into this one again, the project's structure is too painful...

daniejstriata commented 1 year ago

Where is the version of a cli set in a rust project? When you build it or in the code?

Canop commented 1 year ago

For most projects, everything is built from one Cargo.toml version. But for dysk, in order to be able to automatically build a man page, I had to split it with most of the code in a sub project. It means I have to set the version at 4 places (in 2 Cargo.toml files).

I'll probably need to set up something like a git hook to check they're equal...

Canop commented 1 year ago

In retrospect, the automatic man page wasn't worth the pain

Canop commented 1 year ago

This should be fixed at most places now (not when you use crates.io, ie cargo install dysk).

Please don't close the issue, I need to set up a reliable solution to avoid this problem on next deploys.

Canop commented 1 year ago

Made the build impossible when a version is different: image

Stargateur commented 1 year ago

For most projects, everything is built from one Cargo.toml version. But for dysk, in order to be able to automatically build a man page, I had to split it with most of the code in a sub project. It means I have to set the version at 4 places (in 2 Cargo.toml files).

That weird haha.

Canop commented 1 year ago

That weird haha.

Yeah. If you find a cleaner way to generate the man page, it's welcome

daniejstriata commented 1 year ago

What about using environment variables during the build process to inject the version information?

in Cargo.toml

[package]
name = "project"
version = "0.1.0"  # Placeholder version

Use Environment Variables

use std::env;

fn main() {
    // Fetch the version environment variable, defaulting to a fallback if not set
    let version = env::var("PROJECT_VERSION").unwrap_or_else(|_| "unknown".to_string());

    println!("Building version: {}", version);

    // The rest of your build logic
}

Can you then build it with cargo like this?

export PROJECT_VERSION="1.2.3" 
cargo build
Canop commented 1 year ago

@daniejstriata The Cargo.toml file is used in all kind of processes and tools, it should stay correct. I should rather look for another man page generator when I have some free time.

daniejstriata commented 1 year ago

@daniejstriata The Cargo.toml file is used in all kind of processes and tools, it should stay correct. I should rather for another man page generator when I have some free time.

That makes sense. Thanks.

Canop commented 1 year ago

Hint for bored FOSS authors: there's some market for a convenient man page generator for rust projects ;)