diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index beae7286..8d979cd5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -21,7 +21,18 @@ jobs: key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Build run: cargo build --verbose + - name: Run tests run: cargo test --verbose + - name: Run binary for test purpose + shell: bash -xe {0} + run: | + cargo run --profile dev -- --profile dev + test -f target/generate-rpm/cargo-generate-rpm-*.rpm + rm -f target/generate-rpm/cargo-generate-rpm-*.rpm + cargo run --release -- generate-rpm + test -f target/generate-rpm/cargo-generate-rpm-*.rpm + rm -f target/generate-rpm/cargo-generate-rpm-*.rpm + - name: Package run: cargo package diff --git a/src/cli.rs b/src/cli.rs index 6ffd2783..a664ad0d 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -99,16 +99,18 @@ impl Cli { T: Into + Clone, { let mut args = args_fn(); - let matches = if args.nth(1) == Some(OsString::from("generate-rpm")) { + if args.nth(1) == Some(OsString::from("generate-rpm")) { let args = args_fn(); - ::command().get_matches_from(args) + let matches = ::command().get_matches_from(args); + let CargoWrapper::GenerateRpm(arg) = + CargoWrapper::from_arg_matches_mut(&mut matches.clone())?; + Ok((arg, matches)) } else { let args = args_fn(); - ::command().get_matches_from(args) - }; - let arg = Self::from_arg_matches_mut(&mut matches.clone())?; - - Ok((arg, matches)) + let matches = ::command().get_matches_from(args); + let arg = Self::from_arg_matches_mut(&mut matches.clone())?; + Ok((arg, matches)) + } } pub fn get_matches_and_try_parse() -> Result<(Self, ArgMatches), clap::Error> {