Skip to content

Commit

Permalink
Added -version switch
Browse files Browse the repository at this point in the history
  • Loading branch information
agudys authored Oct 22, 2024
1 parent 18719c7 commit 742b494
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ jobs:
steps:
- name: help
run: ./kmer-db

- name: version
run: ./kmer-db -version

########################################################################################
upload:
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GitHub Actions CI
name: Build and tests

on:
push:
Expand Down Expand Up @@ -54,8 +54,13 @@ jobs:
path: ./

- name: untar artifacts
run: |
tar -xf kmer-db.tar
run: tar -xf kmer-db.tar

- name: help
run: ./kmer-db

- name: version
run: ./kmer-db -version

- name: build
run: |
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/self-hosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ jobs:

steps:
- name: help (${{matrix.compiler}}, ${{matrix.mode}})
run: |
${EXEC} ${{matrix.mode}} -help
run: ${EXEC} ${{matrix.mode}} -help

- name: run (${{matrix.compiler}})
run: ${EXEC} -version


########################################################################################
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kmer-db
[![GitHub downloads](https://img.shields.io/github/downloads/refresh-bio/kmer-db/total.svg?style=flag&label=GitHub%20downloads)](https://github.com/refresh-bio/kmer-db/releases)
[![Bioconda downloads](https://img.shields.io/conda/dn/bioconda/kmer-db.svg?style=flag&label=Bioconda%20downloads)](https://anaconda.org/bioconda/kmer-db)
[![GitHub Actions CI](../../workflows/GitHub%20Actions%20CI/badge.svg)](../../actions/workflows/main.yml)
[![Build and tests](../../workflows/Build%20and%20tests/badge.svg)](../../actions/workflows/main.yml)
[![License](https://anaconda.org/bioconda/famsa/badges/license.svg)](https://www.gnu.org/licenses/gpl-3.0.html)

![x86-64](https://img.shields.io/static/v1?label=%E2%80%8B&message=x86-64&color=yellow&logo=PCGamingWiki&logoColor=white)
Expand Down
3 changes: 0 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ int main(int argc, char **argv)
{
Log::getInstance(Log::LEVEL_NORMAL).enable();

LOG_NORMAL << "Kmer-db version " << VERSION << " (" << DATE << ")" << endl
<< "S. Deorowicz, A. Gudys, M. Dlugosz, M. Kokot, and A. Danek (c) 2018" << endl << endl;

Params params;

try {
Expand Down
20 changes: 18 additions & 2 deletions src/params.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "params.h"
#include "types.h"
#include "version.h"

#include <iostream>
#include <stdexcept>
Expand Down Expand Up @@ -61,6 +62,13 @@ bool Params::parse(int argc, char** argv) {
std::vector<string> params(argc - 1);
std::transform(argv + 1, argv + argc, params.begin(), [](char* c)->string { return c; });

if (findSwitch(params, SWITCH_VERSION)) {
LOG_NORMAL << VERSION;
return false;
}

showHeader();

bool helpWanted = findSwitch(params, SWITCH_HELP);
if (params.size() == 0) {
// no arguments or -help switch already consumed
Expand All @@ -71,7 +79,7 @@ bool Params::parse(int argc, char** argv) {
mode = str2mode(params.front());
params.erase(params.begin());

if (helpWanted && params.size() == 0) {
if (helpWanted || params.size() == 0 || mode == Mode::unknown) {
// help for particular mode
showInstructions(mode);
return false;
Expand Down Expand Up @@ -116,7 +124,7 @@ bool Params::parse(int argc, char** argv) {
parse_minhash(params); break;
default:
showInstructions(mode);

return false;
}

// set default fration in minhash mode if not specified
Expand All @@ -130,6 +138,14 @@ bool Params::parse(int argc, char** argv) {
return true;
}

// *****************************************************************************************
//
void Params::showHeader() const {

LOG_NORMAL << "Kmer-db version " << VERSION << " (" << DATE << ")" << endl
<< "S. Deorowicz, A. Gudys, M. Dlugosz, M. Kokot, and A. Danek (c) 2018" << endl << endl;
}

// *****************************************************************************************
//
void Params::showInstructions(Mode mode) const {
Expand Down
3 changes: 3 additions & 0 deletions src/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Params {
const std::string MODE_DISTANCE = "distance";

const std::string SWITCH_HELP = "-help";
const std::string SWITCH_VERSION = "-version";
const std::string SWITCH_KMC_SAMPLES = "-from-kmers";
const std::string SWITCH_MINHASH_SAMPLES = "-from-minhash";
const std::string SWITCH_MULTISAMPLE_FASTA = "-multisample-fasta";
Expand Down Expand Up @@ -104,6 +105,8 @@ class Params {

void showInstructions(Mode mode) const;

void showHeader() const;


bool findSwitch(std::vector<std::string>& params, const std::string& name) const {
auto it = std::find(params.begin(), params.end(), name); // verbose mode
Expand Down
7 changes: 5 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#pragma once

#define VERSION "2.2.2"
#define DATE "04.10.2024"
#define VERSION "2.2.3"
#define DATE "21.10.2024"

/*
Version history
2.2.3 (21.10.2024)
- Added `-version` switch.
2.2.2 (04.10.2024)
- Fixed bug with filtering/sampling in all2all variants and new2all always using 18 as a kmer length.
Expand Down

0 comments on commit 742b494

Please sign in to comment.