fix/improve printing and CLI

This commit is contained in:
Mario Fink 2021-02-11 19:54:09 +01:00
parent 6b41dbe00a
commit 3948bfeac6
3 changed files with 16 additions and 9 deletions

View File

@ -375,9 +375,9 @@ namespace imc
if ( sep == ' ' ) if ( sep == ' ' )
{ {
fou<<std::setw(width)<<std::left<<xname_ fou<<std::setw(width)<<std::left<<xname_
<<std::setw(width)<<std::left<<yname_<<"\n" <<std::setw(width)<<std::left<<yname_<<"\n"
<<std::setw(width)<<std::left<<xunit_ <<std::setw(width)<<std::left<<xunit_
<<std::setw(width)<<std::left<<yunit_<<"\n"; <<std::setw(width)<<std::left<<yunit_<<"\n";
} }
else else
{ {
@ -388,7 +388,8 @@ namespace imc
{ {
if ( sep == ' ' ) if ( sep == ' ' )
{ {
fou<<std::setw(width)<<std::left<<xdata_[i] fou<<std::setprecision(9)<<std::fixed
<<std::setw(width)<<std::left<<xdata_[i]
<<std::setw(width)<<std::left<<ydata_[i]<<"\n"; <<std::setw(width)<<std::left<<ydata_[i]<<"\n";
} }
else else

View File

@ -329,7 +329,7 @@ namespace imc
{ {
// check for given directory // check for given directory
std::filesystem::path pd = output; std::filesystem::path pd = output;
if ( std::filesystem::is_directory(pd) ) if ( !std::filesystem::is_directory(pd) )
{ {
throw std::runtime_error("given directory does not exist"); throw std::runtime_error("given directory does not exist");
} }
@ -338,7 +338,9 @@ namespace imc
it != channels_.end(); ++it) it != channels_.end(); ++it)
{ {
// construct filename // construct filename
std::string filenam = std::string("channel_") + it->first + std::string(".csv"); std::string chid = std::string("channel_") + it->first;
std::string filenam = it->second.name_.empty() ? chid + std::string(".csv")
: it->second.name_ + std::string(".csv");
std::filesystem::path pf = pd / filenam; std::filesystem::path pf = pd / filenam;
// and print the channel // and print the channel

View File

@ -119,7 +119,7 @@ void show_usage()
// <<" -g, --listgroups list channelgroups\n" // <<" -g, --listgroups list channelgroups\n"
<<" -c, --listchannels list channels\n" <<" -c, --listchannels list channels\n"
<<" -b, --listblocks list IMC key-blocks\n" <<" -b, --listblocks list IMC key-blocks\n"
<<" -d, --output output directory\n" <<" -d, --output output directory to print channels\n"
<<" -h, --help show this help message \n" <<" -h, --help show this help message \n"
<<" -v, --version display version\n" <<" -v, --version display version\n"
<<"\n"; <<"\n";
@ -198,9 +198,13 @@ int main(int argc, char* argv[])
} }
// print channel(s) to certain directory // print channel(s) to certain directory
if ( cfgopts.count("directory") == 1 ) if ( cfgopts.count("output") == 1 )
{ {
std::cout<<cfgopts.at("directory")<<"\n"; try {
imcraw.print_channels(cfgopts.at("output"));
} catch (const std::exception& e) {
std::cerr<<"failed to print channels for "<<rawfile<<": "<<e.what()<<"\n";
}
} }
} }